Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update auto/default to true in RECEPTOR_KUBE_SUPPORT_RECONNECT #940

Merged
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
8 changes: 4 additions & 4 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ func (kw *kubeUnit) runWorkUsingLogger() {
func shouldUseReconnect() bool {
// Support for streaming from pod with timestamps using reconnect method is in all current versions
// Can override the detection by setting the RECEPTOR_KUBE_SUPPORT_RECONNECT
// accepted values: "enabled", "disabled", "auto" with "disabled" being the default
// all invalid value will assume to be "disabled"
// accepted values: "enabled", "disabled", "auto". The default is "enabled"
// all invalid values will assume to be "disabled"

env, ok := os.LookupEnv("RECEPTOR_KUBE_SUPPORT_RECONNECT")
if ok {
Expand All @@ -771,13 +771,13 @@ func shouldUseReconnect() bool {
case "disabled":
return false
case "auto":
// continue
return true
default:
return false
}
}

return false
return true
}

func parseTime(s string) *time.Time {
Expand Down
4 changes: 2 additions & 2 deletions pkg/workceptor/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestShouldUseReconnect(t *testing.T) {
{
name: "Positive (undefined) test",
envValue: "",
want: false,
want: true,
},
{
name: "Enabled test",
Expand All @@ -33,7 +33,7 @@ func TestShouldUseReconnect(t *testing.T) {
{
name: "Auto test",
envValue: "auto",
want: false,
want: true,
},
{
name: "Default test",
Expand Down
24 changes: 16 additions & 8 deletions tests/functional/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ func TestListeners(t *testing.T) {
defer cmd.Process.Wait()
defer cmd.Process.Kill()

ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
success, err := utils.CheckUntilTimeoutWithErr(ctx, 10*time.Millisecond, func() (bool, error) {
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel1()

success, err := utils.CheckUntilTimeoutWithErr(ctx1, 10*time.Millisecond, func() (bool, error) {
return ConfirmListening(cmd.Process.Pid, listenProto)
})
if err != nil {
Expand Down Expand Up @@ -116,8 +118,10 @@ func TestSSLListeners(t *testing.T) {
return err == nil
}

ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
success := utils.CheckUntilTimeout(ctx, 10*time.Millisecond, checkFunc)
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel1()

success := utils.CheckUntilTimeout(ctx1, 10*time.Millisecond, checkFunc)
if !success {
t.Fatalf("Timed out while waiting for tls backend to start:\n%s", receptorStdOut.String())
}
Expand Down Expand Up @@ -190,8 +194,10 @@ func TestCostMap(t *testing.T) {
defer cmd.Process.Wait()
defer cmd.Process.Kill()

ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
success, err := utils.CheckUntilTimeoutWithErr(ctx, 10*time.Millisecond, func() (bool, error) {
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel1()

success, err := utils.CheckUntilTimeoutWithErr(ctx1, 10*time.Millisecond, func() (bool, error) {
return ConfirmListening(cmd.Process.Pid, listenProto)
})
if err != nil {
Expand Down Expand Up @@ -238,8 +244,10 @@ func TestCosts(t *testing.T) {
defer cmd.Process.Wait()
defer cmd.Process.Kill()

ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
success, err := utils.CheckUntilTimeoutWithErr(ctx, 10*time.Millisecond, func() (bool, error) {
ctx1, cancel1 := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel1()

success, err := utils.CheckUntilTimeoutWithErr(ctx1, 10*time.Millisecond, func() (bool, error) {
return ConfirmListening(cmd.Process.Pid, listenProto)
})
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions tests/functional/mesh/firewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ func TestFirewall(t *testing.T) {
t.Fatal(err)
}

ctx, _ := context.WithTimeout(context.Background(), 20*time.Second)
err = m.WaitForReady(ctx)
ctx1, cancel1 := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel1()

err = m.WaitForReady(ctx1)
if err != nil {
t.Fatal(err)
}
Expand Down
29 changes: 19 additions & 10 deletions tests/functional/mesh/mesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ func TestMeshStartup(t *testing.T) {
t.Fatal(err)
}

ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
err = m.WaitForReady(ctx)
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel1()

err = m.WaitForReady(ctx1)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -109,8 +111,10 @@ func TestTraceroute(t *testing.T) {
t.Fatal(err)
}

ctx, _ := context.WithTimeout(context.Background(), 60*time.Second)
err = m.WaitForReady(ctx)
ctx1, cancel1 := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel1()

err = m.WaitForReady(ctx1)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -212,8 +216,9 @@ func TestMeshShutdown(t *testing.T) {
t.Fatal(err)
}

ctx, _ := context.WithTimeout(context.Background(), 60*time.Second)
err = m.WaitForReady(ctx)
ctx1, cancel1 := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel1()
err = m.WaitForReady(ctx1)

if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -288,8 +293,10 @@ func TestCosts(t *testing.T) {
defer m.WaitForShutdown()
defer m.Destroy()

ctx, _ := context.WithTimeout(context.Background(), 60*time.Second)
err = m.WaitForReady(ctx)
ctx1, cancel1 := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel1()

err = m.WaitForReady(ctx1)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -351,9 +358,11 @@ func TestDuplicateNodes(t *testing.T) {
t.Fatal(err)
}

ctx, _ := context.WithTimeout(context.Background(), 1*time.Minute)
ctx1, cancel1 := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel1()

sleepInterval := 100 * time.Millisecond
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
return strings.Contains(m.LogWriter.String(), "connected using a node ID we are already connected to")
}) {
t.Fatal("duplicate nodes were not expected to exist together")
Expand Down
30 changes: 20 additions & 10 deletions tests/functional/mesh/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ func TestTCPSSLConnections(t *testing.T) {
defer m.WaitForShutdown()
defer m.Destroy()

ctx, _ := context.WithTimeout(context.Background(), 20*time.Second)
err = m.WaitForReady(ctx)
ctx1, cancel1 := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel1()

err = m.WaitForReady(ctx1)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -187,9 +189,11 @@ func TestTCPSSLClientAuthFailNoKey(t *testing.T) {
defer m.WaitForShutdown()
defer m.Destroy()

ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel1()

sleepInterval := 100 * time.Millisecond
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
linuxTLSError := strings.Contains(m.LogWriter.String(), "certificate signed by unknown authority")
macTLSError := strings.Contains(m.LogWriter.String(), "certificate is not trusted")

Expand Down Expand Up @@ -265,9 +269,11 @@ func TestTCPSSLClientAuthFailBadKey(t *testing.T) {
defer m.WaitForShutdown()
defer m.Destroy()

ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel1()

sleepInterval := 100 * time.Millisecond
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
linuxTLSError := strings.Contains(m.LogWriter.String(), "certificate signed by unknown authority")
macTLSError := strings.Contains(m.LogWriter.String(), "certificate is not trusted")

Expand Down Expand Up @@ -330,9 +336,11 @@ func TestTCPSSLServerAuthFailNoKey(t *testing.T) {
defer m.WaitForShutdown()
defer m.Destroy()

ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel1()

sleepInterval := 100 * time.Millisecond
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
return strings.Contains(m.LogWriter.String(), "first record does not look like a TLS handshake")
}) {
t.Fatal("Expected connection to fail but it succeeded")
Expand Down Expand Up @@ -402,9 +410,11 @@ func TestTCPSSLServerAuthFailBadKey(t *testing.T) {
defer m.WaitForShutdown()
defer m.Destroy()

ctx, _ := context.WithTimeout(context.Background(), 5*time.Minute)
ctx1, cancel1 := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel1()

sleepInterval := 100 * time.Millisecond
if !utils.CheckUntilTimeout(ctx, sleepInterval, func() bool {
if !utils.CheckUntilTimeout(ctx1, sleepInterval, func() bool {
linuxTLSError := strings.Contains(m.LogWriter.String(), "certificate signed by unknown authority")
macTLSError := strings.Contains(m.LogWriter.String(), "certificate is not trusted")

Expand Down
Loading
Loading