-
Notifications
You must be signed in to change notification settings - Fork 118
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
[WIP]OSSM-5881 Do not require ingress and egress gateways when spec.cluster.multiCluster
is enabled
#1643
base: maistra-2.4
Are you sure you want to change the base?
[WIP]OSSM-5881 Do not require ingress and egress gateways when spec.cluster.multiCluster
is enabled
#1643
Changes from 9 commits
7177a0e
8cdf0a3
f43ecc0
5418648
3e62d89
e79f64d
963529d
e891d97
25a13be
1de63a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1034,3 +1034,67 @@ func TestSecurityConversionFromV2ToV1(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
type multiClusterTestCase struct { | ||
name string | ||
spec *v2.ControlPlaneSpec | ||
expectedHelmValues v1.HelmValues | ||
} | ||
|
||
var multiClusterTestCases = []multiClusterTestCase{ | ||
{ | ||
name: "MultiCluster_v2_4", | ||
spec: &v2.ControlPlaneSpec{ | ||
Version: versions.V2_4.String(), | ||
Cluster: &v2.ControlPlaneClusterConfig{ | ||
Name: "my-cluster", | ||
Network: "my-network", | ||
MultiCluster: &v2.MultiClusterConfig{ | ||
Enablement: v2.Enablement{ | ||
Enabled: &featureEnabled, | ||
}, | ||
}, | ||
}, | ||
Gateways: &v2.GatewaysConfig{ | ||
Enablement: v2.Enablement{ | ||
Enabled: &featureDisabled, | ||
}, | ||
}, | ||
}, | ||
expectedHelmValues: buildHelmValues(` | ||
global: | ||
multiCluster: | ||
enabled: true | ||
gateways: | ||
enabled: false | ||
`), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These values are obviously incorrect, so this test fails as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I run the test locally it is asking me to add a bunch of stuff, should I keep it to what you had put into the jira? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You should never adjust expected test data to the actual result just to make the test pass. Your test and data should drive the implementation, so first fix the expected helm values and the input (SMCP spec) and then work on the implementation until it passes for the correct input and output.
In JIRA I added only SMCP spec. You can use that YAML to properly configure input SMCP in your test. |
||
}, | ||
} | ||
|
||
func TestMultiClusterGatewaysDisabled(t *testing.T) { | ||
for _, tc := range multiClusterTestCases { | ||
t.Run(tc.name+"-v2_to_v1", func(t *testing.T) { | ||
var specV1 v1.ControlPlaneSpec | ||
if err := Convert_v2_ControlPlaneSpec_To_v1_ControlPlaneSpec(tc.spec.DeepCopy(), &specV1, nil); err != nil { | ||
t.Errorf("failed to convert SMCP v2 to v1: %s", err) | ||
} | ||
|
||
if !reflect.DeepEqual(tc.expectedHelmValues.DeepCopy(), specV1.Istio.DeepCopy()) { | ||
t.Errorf("unexpected output converting v2 to values:\n\texpected:\n%#v\n\tgot:\n%#v", tc.expectedHelmValues.GetContent(), specV1.Istio.GetContent()) | ||
} | ||
}) | ||
|
||
t.Run(tc.name+"-v1_to_v2", func(t *testing.T) { | ||
specV1 := v1.ControlPlaneSpec{ | ||
Istio: tc.expectedHelmValues.DeepCopy(), | ||
} | ||
specV2 := v2.ControlPlaneSpec{} | ||
if err := Convert_v1_ControlPlaneSpec_To_v2_ControlPlaneSpec(&specV1, &specV2, nil); err != nil { | ||
t.Errorf("failed to convert SMCP v1 to v2: %s", err) | ||
} | ||
|
||
assertEquals(t, tc.spec.Cluster, specV2.Cluster) | ||
assertEquals(t, tc.spec.Gateways, specV2.Gateways) | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You modified cluster.go, so I would expect to see appropriate tests in cluster_test.go.