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

fix: ExternalTargetCANamespace name #2637

Merged
merged 1 commit into from
Jun 26, 2024
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: 7 additions & 1 deletion cli/connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func newCmdConnectivityTest(hooks api.Hooks) *cobra.Command {
cmd.Flags().BoolVarP(&params.Timestamp, "timestamp", "t", false, "Show timestamp in messages")
cmd.Flags().BoolVarP(&params.PauseOnFail, "pause-on-fail", "p", false, "Pause execution on test failure")
cmd.Flags().StringVar(&params.ExternalTarget, "external-target", "one.one.one.one.", "Domain name to use as external target in connectivity tests")
cmd.Flags().StringVar(&params.ExternalTargetCANamespace, "external-target-ca-namespace", defaults.ConnectivityCheckNamespace, "Namespace of the CA secret for the external target. Used by client-egress-l7-tls test cases.")
cmd.Flags().StringVar(&params.ExternalTargetCANamespace, "external-target-ca-namespace", "", "Namespace of the CA secret for the external target. Used by client-egress-l7-tls test cases.")
cmd.Flags().StringVar(&params.ExternalTargetCAName, "external-target-ca-name", "cabundle", "Name of the CA secret for the external target. Used by client-egress-l7-tls test cases.")
cmd.Flags().StringVar(&params.ExternalCIDR, "external-cidr", "1.0.0.0/8", "CIDR to use as external target in connectivity tests")
cmd.Flags().StringVar(&params.ExternalIP, "external-ip", "1.1.1.1", "IP to use as external target in connectivity tests")
Expand Down Expand Up @@ -228,6 +228,9 @@ func newConnectivityTests(params check.Parameters, logger *check.ConcurrentLogge
params.TestConcurrency = 1
}
if params.TestConcurrency < 2 {
if params.ExternalTargetCANamespace == "" {
params.ExternalTargetCANamespace = defaults.ConnectivityCheckNamespace
}
cc, err := check.NewConnectivityTest(k8sClient, params, defaults.CLIVersion, logger)
if err != nil {
return nil, err
Expand All @@ -239,6 +242,9 @@ func newConnectivityTests(params check.Parameters, logger *check.ConcurrentLogge
for i := 0; i < params.TestConcurrency; i++ {
params := params
params.TestNamespace = fmt.Sprintf("%s-%d", params.TestNamespace, i+1)
if params.ExternalTargetCANamespace == "" {
params.ExternalTargetCANamespace = params.TestNamespace
}
params.ExternalDeploymentPort += i
params.EchoServerHostPort += i
params.JunitFile = junit.NamespacedFileName(params.TestNamespace, params.JunitFile)
Expand Down
65 changes: 48 additions & 17 deletions cli/connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,63 @@ import (

func TestNewConnectivityTests(t *testing.T) {
testCases := []struct {
params check.Parameters
expectedCount int
expectedTestNamespaces []string
params check.Parameters
expectedCount int
expectedTestNamespaces []string
expectedExternalTargetCANamespace []string
}{
{
params: check.Parameters{
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
ExternalTargetCANamespace: "",
},
expectedCount: 1,
expectedTestNamespaces: []string{"cilium-test"},
expectedCount: 1,
expectedTestNamespaces: []string{"cilium-test"},
expectedExternalTargetCANamespace: []string{"cilium-test"},
},
{
params: check.Parameters{
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
TestConcurrency: -1,
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
ExternalTargetCANamespace: "cilium-test",
},
expectedCount: 1,
expectedTestNamespaces: []string{"cilium-test"},
expectedCount: 1,
expectedTestNamespaces: []string{"cilium-test"},
expectedExternalTargetCANamespace: []string{"cilium-test"},
},
{
params: check.Parameters{
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
TestConcurrency: 3,
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
ExternalTargetCANamespace: "cilium-test",
TestConcurrency: -1,
},
expectedCount: 3,
expectedTestNamespaces: []string{"cilium-test-1", "cilium-test-2", "cilium-test-3"},
expectedCount: 1,
expectedTestNamespaces: []string{"cilium-test"},
expectedExternalTargetCANamespace: []string{"cilium-test"},
},
{
params: check.Parameters{
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
ExternalTargetCANamespace: "",
TestConcurrency: 3,
},
expectedCount: 3,
expectedTestNamespaces: []string{"cilium-test-1", "cilium-test-2", "cilium-test-3"},
expectedExternalTargetCANamespace: []string{"cilium-test-1", "cilium-test-2", "cilium-test-3"},
},
{
params: check.Parameters{
FlowValidation: check.FlowValidationModeDisabled,
TestNamespace: "cilium-test",
ExternalTargetCANamespace: "cilium-test",
TestConcurrency: 3,
},
expectedCount: 3,
expectedTestNamespaces: []string{"cilium-test-1", "cilium-test-2", "cilium-test-3"},
expectedExternalTargetCANamespace: []string{"cilium-test"},
},
}
for _, tt := range testCases {
Expand All @@ -54,5 +82,8 @@ func TestNewConnectivityTests(t *testing.T) {
for i, n := range tt.expectedTestNamespaces {
require.Equal(t, n, actual[i].Params().TestNamespace)
}
for i, n := range tt.expectedExternalTargetCANamespace {
require.Equal(t, n, actual[i].Params().ExternalTargetCANamespace)
}
}
}
Loading