Skip to content

Commit

Permalink
msi: keep TD_AGENT_TOPDIR (#542)
Browse files Browse the repository at this point in the history
Signed-off-by: Daijiro Fukuda <fukuda@clear-code.com>
  • Loading branch information
daipom authored Jul 25, 2023
1 parent 24577a1 commit 89a8a7b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ jobs:
--volume ${PWD}:C:\fluentd:ro `
mcr.microsoft.com/dotnet/framework/runtime:3.5 `
powershell -ExecutionPolicy Bypass -Command "C:\fluentd\fluent-package\msi\install-test.ps1"
- name: Migration From v4 Test
shell: pwsh
run: |
docker run `
--rm `
--tty `
--volume ${PWD}:C:\fluentd:ro `
mcr.microsoft.com/dotnet/framework/runtime:3.5 `
powershell -ExecutionPolicy Bypass -Command "C:\fluentd\fluent-package\msi\update-from-v4-test.ps1"
- name: Serverspec Test
shell: pwsh
run: |
Expand Down
7 changes: 7 additions & 0 deletions fluent-package/msi/source.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@
System="yes"
Name="FLUENT_PACKAGE_TOPDIR"
Value="[FLUENTPROJECTLOCATION]"/>
<Environment Id="CompatProjectLocationDirForConf"
Action="set"
Permanent="no"
Part="all"
System="yes"
Name="TD_AGENT_TOPDIR"
Value="[OPTLOCATION]td-agent\"/>
</Component>
</DirectoryRef>

Expand Down
52 changes: 52 additions & 0 deletions fluent-package/msi/update-from-v4-test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-PSDebug -Trace 1

# Install v4
Invoke-WebRequest "https://s3.amazonaws.com/packages.treasuredata.com/4/windows/td-agent-4.5.0-x64.msi" -OutFile "td-agent-4.5.0-x64.msi"
Start-Process msiexec -ArgumentList "/i", "td-agent-4.5.0-x64.msi", "/quiet" -Wait -NoNewWindow
Start-Sleep 30 # Must wait until all processes are surely started.
$test_setting = @'
<source>
@type sample
tag test
</source>
<match test>
@type file
path "#{ENV['TD_AGENT_TOPDIR']}/output/test"
<buffer []>
@type memory
flush_mode immediate
</buffer>
</match>
'@
Add-Content -Path "C:\\opt\\td-agent\\etc\\td-agent\\td-agent.conf" -Encoding UTF8 -Value $test_setting
Restart-Service fluentdwinsvc
Start-Sleep 30 # Must wait until all processes are surely started.

# Update to v5
$new_package = ((Get-Item "C:\\fluentd\\fluent-package\\msi\\repositories\\fluent-package-*.msi") | Sort-Object -Descending { $_.LastWriteTime } | Select-Object -First 1).FullName
Start-Process msiexec -ArgumentList "/i", $new_package, "/quiet" -Wait -NoNewWindow
Start-Service fluentdwinsvc
Start-Sleep 30 # Must wait until all processes are surely started.

# Test: Access to the configs with the old path
If (-Not (Test-Path "C:\\opt\\td-agent\\etc\\td-agent\\fluentd.conf")) {
[Environment]::Exit(1)
}
If (-Not (Test-Path "C:\\opt\\td-agent\\etc\\td-agent\\td-agent.conf")) {
[Environment]::Exit(1)
}

# Test: Keep the old log files
If ((Get-ChildItem "C:\\opt\\td-agent\\*.log").Count -eq 0) {
[Environment]::Exit(1)
}

# Test: The previous config works as before
$output_files = Get-ChildItem "C:\\opt\\td-agent\\output"
Start-Sleep 5
$output_files_after_sleep = Get-ChildItem "C:\\opt\\td-agent\\output"
If ($output_files_after_sleep.Count -le $output_files.Count) {
[Environment]::Exit(1)
}

0 comments on commit 89a8a7b

Please sign in to comment.