@@ -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 jsonConfig := "{\" global\" :{\" acl_token\" :\" badtoken\" }}"
@@ -329,10 +355,10 @@ func TestConsulTopoWithAuthFailure(t *testing.T) {
329355func TestConsulWatcherStormPrevention (t * testing.T ) {
330356 // Save original values and restore them after the test
331357 originalWatchPollDuration := watchPollDuration
332- originalAuthFile := consulAuthClientStaticFile
358+ originalConsulAuthClientStaticFile := consulAuthClientStaticFile
333359 defer func () {
334360 watchPollDuration = originalWatchPollDuration
335- consulAuthClientStaticFile = originalAuthFile
361+ consulAuthClientStaticFile = originalConsulAuthClientStaticFile
336362 }()
337363
338364 // Configure test settings - using direct assignment since flag parsing in tests is complex
@@ -351,7 +377,9 @@ func TestConsulWatcherStormPrevention(t *testing.T) {
351377 os .Remove (configFilename )
352378 }()
353379
354- ctx := context .Background ()
380+ ctx , cancel := context .WithCancel (context .Background ())
381+ defer cancel ()
382+
355383 testRoot := "storm-test"
356384
357385 // Create the topo server
0 commit comments