Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions go/vt/topo/consultopo/server_flaky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ func startConsul(t *testing.T, authToken string) (*exec.Cmd, string, string) {
}

func TestConsulTopo(t *testing.T) {
originalWatchPollDuration := watchPollDuration
defer func() {
watchPollDuration = originalWatchPollDuration
}()

// One test is going to wait that full period, so make it shorter.
watchPollDuration = 100 * time.Millisecond

Expand All @@ -150,6 +155,7 @@ func TestConsulTopo(t *testing.T) {
testIndex := 0
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

test.TopoServerTestSuite(t, ctx, func() *topo.Server {
// Each test will use its own sub-directories.
testRoot := fmt.Sprintf("test-%v", testIndex)
Expand All @@ -175,6 +181,16 @@ func TestConsulTopo(t *testing.T) {

func TestConsulTopoWithChecks(t *testing.T) {
// One test is going to wait that full period, so make it shorter.
originalWatchPollDuration := watchPollDuration
originalConsulLockSessionChecks := consulLockSessionChecks
originalConsulLockSessionTTL := consulLockSessionTTL

defer func() {
watchPollDuration = originalWatchPollDuration
consulLockSessionTTL = originalConsulLockSessionTTL
consulLockSessionChecks = originalConsulLockSessionChecks
}()

watchPollDuration = 100 * time.Millisecond
consulLockSessionChecks = "serfHealth"
consulLockSessionTTL = "15s"
Expand Down Expand Up @@ -248,6 +264,11 @@ func TestConsulTopoWithAuth(t *testing.T) {
}
defer os.Remove(tmpFile.Name())

originalConsulAuthClientStaticFile := consulAuthClientStaticFile
defer func() {
consulAuthClientStaticFile = originalConsulAuthClientStaticFile
}()

consulAuthClientStaticFile = tmpFile.Name()

jsonConfig := "{\"global\":{\"acl_token\":\"123456\"}, \"test\":{\"acl_token\":\"123456\"}}"
Expand Down Expand Up @@ -299,6 +320,11 @@ func TestConsulTopoWithAuthFailure(t *testing.T) {
}
defer os.Remove(tmpFile.Name())

originalConsulAuthClientStaticFile := consulAuthClientStaticFile
defer func() {
consulAuthClientStaticFile = originalConsulAuthClientStaticFile
}()

consulAuthClientStaticFile = tmpFile.Name()

// check valid, empty json causes error
Expand Down Expand Up @@ -346,10 +372,10 @@ func TestConsulTopoWithAuthFailure(t *testing.T) {
func TestConsulWatcherStormPrevention(t *testing.T) {
// Save original values and restore them after the test
originalWatchPollDuration := watchPollDuration
originalAuthFile := consulAuthClientStaticFile
originalConsulAuthClientStaticFile := consulAuthClientStaticFile
defer func() {
watchPollDuration = originalWatchPollDuration
consulAuthClientStaticFile = originalAuthFile
consulAuthClientStaticFile = originalConsulAuthClientStaticFile
}()

// Configure test settings - using direct assignment since flag parsing in tests is complex
Expand All @@ -368,7 +394,9 @@ func TestConsulWatcherStormPrevention(t *testing.T) {
os.Remove(configFilename)
}()

ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

testRoot := "storm-test"

// Create the topo server
Expand Down
8 changes: 8 additions & 0 deletions go/vt/vtadmin/vtctldclient/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ func TestDialSecureDialOptionError(t *testing.T) {
// Parse the flags which will set the cert and key variables in grpcclientcommon
err = fs.Parse(os.Args[1:])
require.NoError(t, err)
// reset flags after test
defer func() {
_ = fs.Parse([]string{
"vtadmin",
"--vtctld-grpc-cert=",
"--vtctld-grpc-key=",
})
}()

// Now when we create a proxy, it should fail at line 116
disco := fakediscovery.New()
Expand Down
Loading