@@ -128,6 +128,11 @@ func startConsul(t *testing.T, authToken string) (*exec.Cmd, string, string) {
128128}
129129
130130func TestConsulTopo (t * testing.T ) {
131+ originalWatchPollDuration := watchPollDuration
132+ defer func () {
133+ watchPollDuration = originalWatchPollDuration
134+ }()
135+
131136 // One test is going to wait that full period, so make it shorter.
132137 watchPollDuration = 100 * time .Millisecond
133138
@@ -150,6 +155,7 @@ func TestConsulTopo(t *testing.T) {
150155 testIndex := 0
151156 ctx , cancel := context .WithCancel (context .Background ())
152157 defer cancel ()
158+
153159 test .TopoServerTestSuite (t , ctx , func () * topo.Server {
154160 // Each test will use its own sub-directories.
155161 testRoot := fmt .Sprintf ("test-%v" , testIndex )
@@ -175,6 +181,16 @@ func TestConsulTopo(t *testing.T) {
175181
176182func TestConsulTopoWithChecks (t * testing.T ) {
177183 // One test is going to wait that full period, so make it shorter.
184+ originalWatchPollDuration := watchPollDuration
185+ originalConsulLockSessionChecks := consulLockSessionChecks
186+ originalConsulLockSessionTTL := consulLockSessionTTL
187+
188+ defer func () {
189+ watchPollDuration = originalWatchPollDuration
190+ consulLockSessionTTL = originalConsulLockSessionTTL
191+ consulLockSessionChecks = originalConsulLockSessionChecks
192+ }()
193+
178194 watchPollDuration = 100 * time .Millisecond
179195 consulLockSessionChecks = "serfHealth"
180196 consulLockSessionTTL = "15s"
@@ -248,6 +264,11 @@ func TestConsulTopoWithAuth(t *testing.T) {
248264 }
249265 defer os .Remove (tmpFile .Name ())
250266
267+ originalConsulAuthClientStaticFile := consulAuthClientStaticFile
268+ defer func () {
269+ consulAuthClientStaticFile = originalConsulAuthClientStaticFile
270+ }()
271+
251272 consulAuthClientStaticFile = tmpFile .Name ()
252273
253274 jsonConfig := "{\" global\" :{\" acl_token\" :\" 123456\" }, \" test\" :{\" acl_token\" :\" 123456\" }}"
@@ -299,6 +320,11 @@ func TestConsulTopoWithAuthFailure(t *testing.T) {
299320 }
300321 defer os .Remove (tmpFile .Name ())
301322
323+ originalConsulAuthClientStaticFile := consulAuthClientStaticFile
324+ defer func () {
325+ consulAuthClientStaticFile = originalConsulAuthClientStaticFile
326+ }()
327+
302328 consulAuthClientStaticFile = tmpFile .Name ()
303329
304330 // check valid, empty json causes error
@@ -346,10 +372,10 @@ func TestConsulTopoWithAuthFailure(t *testing.T) {
346372func TestConsulWatcherStormPrevention (t * testing.T ) {
347373 // Save original values and restore them after the test
348374 originalWatchPollDuration := watchPollDuration
349- originalAuthFile := consulAuthClientStaticFile
375+ originalConsulAuthClientStaticFile := consulAuthClientStaticFile
350376 defer func () {
351377 watchPollDuration = originalWatchPollDuration
352- consulAuthClientStaticFile = originalAuthFile
378+ consulAuthClientStaticFile = originalConsulAuthClientStaticFile
353379 }()
354380
355381 // Configure test settings - using direct assignment since flag parsing in tests is complex
@@ -368,7 +394,9 @@ func TestConsulWatcherStormPrevention(t *testing.T) {
368394 os .Remove (configFilename )
369395 }()
370396
371- ctx := context .Background ()
397+ ctx , cancel := context .WithCancel (context .Background ())
398+ defer cancel ()
399+
372400 testRoot := "storm-test"
373401
374402 // Create the topo server
0 commit comments