Skip to content

Commit

Permalink
CI: Check time to start service on Windows (#637)
Browse files Browse the repository at this point in the history
Add a test for #618
On v5.0.2, I have confirmed it takes 4.6s ~ 6.7s.
Since v5.0.3, it takes less than 1s.

Signed-off-by: Daijiro Fukuda <[email protected]>
Co-authored-by: Kentaro Hayashi <[email protected]>
  • Loading branch information
daipom and kenhys authored Mar 27, 2024
1 parent f41c9e3 commit 9d71876
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions fluent-package/msi/install-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,35 @@ $msi = ((Get-Item "C:\\fluentd\\fluent-package\\msi\\repositories\\fluent-packag
Write-Host "Installing ${msi} ..."

Start-Process msiexec -ArgumentList "/i", $msi, "/quiet" -Wait -NoNewWindow
Start-Service fluentdwinsvc
$initialStatus = (Get-Service fluentdwinsvc).Status
if ($initialStatus -ne "Stopped") {
Write-Host "The initial status must be 'Stopped', but it was '${initialStatus}'."
[Environment]::Exit(1)
}

$ENV:PATH="C:\\opt\\fluent\\bin;" + $ENV:PATH
$ENV:PATH="C:\\opt\\fluent;" + $ENV:PATH

td-agent --version

Start-Sleep 3
# https://github.com/fluent/fluent-package-builder/issues/618
$thresholdSeconds = 6
Write-Host "Measuring times to start the service..."
$timeSpans = 0..2 | % {
Measure-Command { Start-Service fluentdwinsvc }
Start-Sleep 15
Stop-Service fluentdwinsvc
Start-Sleep 15
}
Write-Host "Measured seconds to start the service:"
$timeSpans | %{ Write-Host $_.TotalSeconds }
if (($timeSpans | Measure-Object -Property TotalSeconds -Maximum).Maximum -gt $thresholdSeconds) {
# It should be 0.5s ~ 3s because starting service should be done immediately.
# (The only things that take time are starting Ruby and loading the libraries.)
Write-Host "Launching is abnormally slow. (The max value is greater than ${thresholdSeconds}s)"
[Environment]::Exit(1)
}

Get-ChildItem "C:\\opt\\fluent\\*.log" | %{
if (Select-String -Path $_ -Pattern "[warn]", "[error]", "[fatal]" -SimpleMatch -Quiet) {
Write-Host "There are abnormal level logs in ${_}:"
Expand Down

0 comments on commit 9d71876

Please sign in to comment.