Skip to content

Commit bf13310

Browse files
committed
Prevent state-svc cleanup logic from running in TestSingleSvc under certain circumstances.
1 parent 363402e commit bf13310

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

cmd/state-svc/test/integration/svc_int_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ func (suite *SvcIntegrationTestSuite) TestSingleSvc() {
163163
time.Sleep(2 * time.Second) // allow for some time to stop the existing available process
164164

165165
oldCount := suite.GetNumStateSvcProcesses() // may be non-zero due to non-test state-svc processes (using different sock file)
166-
suite.T().Log("oldCount: ", oldCount)
167166
for i := 1; i <= 10; i++ {
168167
go ts.SpawnCmdWithOpts(ts.Exe, e2e.OptArgs("--version"))
169-
time.Sleep(100 * time.Millisecond) // do not spam CPU
168+
time.Sleep(50 * time.Millisecond) // do not spam CPU
170169
}
171170
time.Sleep(2 * time.Second) // allow for some time to spawn the processes
172171

@@ -184,6 +183,16 @@ func (suite *SvcIntegrationTestSuite) TestSingleSvc() {
184183
// with due to other integration tests not always waiting for state-svc to have fully shut down before running the next test
185184
suite.Fail(fmt.Sprintf("spawning multiple state processes should only result in one more state-svc process at most, newCount: %d, oldCount: %d", newCount, oldCount))
186185
}
186+
187+
// ts.Close() has logic to stop state-svc if ts.SvcExe exists.
188+
// It does this by invoking `state-svc stop`.
189+
// However, in the event we end up with less services than anticipated, `state-svc stop` will
190+
// fail with a non-zero exit code because there is no service to stop, and this will cause a
191+
// timeout error in ts.Close().
192+
// In order to prevent this, change ts.SvcExe to something that doesn't exist.
193+
if newCount < oldCount+1 {
194+
ts.SvcExe = "does-not-exist"
195+
}
187196
}
188197

189198
func (suite *SvcIntegrationTestSuite) GetNumStateSvcProcesses() int {

0 commit comments

Comments
 (0)