Skip to content

Commit

Permalink
Use shipyard framework By instaed of ginkgo By
Browse files Browse the repository at this point in the history
This alows flexibility to format or omit the output.

Related to submariner-io/subctl#131

Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Apr 2, 2024
1 parent c5e5e60 commit eb536b4
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 68 deletions.
18 changes: 9 additions & 9 deletions test/e2e/cluster/add_remove_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ var _ = PDescribe("[expansion] Test expanding/shrinking an existing cluster flee
clusterBName := framework.TestContext.ClusterIDs[framework.ClusterB]
clusterCName := framework.TestContext.ClusterIDs[framework.ClusterC]

By(fmt.Sprintf("Verifying no GW nodes are present on cluster %q", clusterCName))
framework.By(fmt.Sprintf("Verifying no GW nodes are present on cluster %q", clusterCName))
gatewayNode := framework.FindGatewayNodes(framework.ClusterC)
Expect(gatewayNode).To(BeEmpty(), fmt.Sprintf("Expected no gateway node on %q", framework.ClusterC))

By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a pod in cluster %q", clusterAName, clusterCName))
framework.By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a pod in cluster %q", clusterAName, clusterCName))
tcp.RunNoConnectivityTest(tcp.ConnectivityTestParams{
Framework: f,
FromCluster: framework.ClusterA,
Expand All @@ -49,7 +49,7 @@ var _ = PDescribe("[expansion] Test expanding/shrinking an existing cluster flee
ToClusterScheduling: framework.NonGatewayNode,
})

By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a service in cluster %q", clusterBName, clusterCName))
framework.By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a service in cluster %q", clusterBName, clusterCName))
tcp.RunNoConnectivityTest(tcp.ConnectivityTestParams{
Framework: f,
ToEndpointType: tcp.ServiceIP,
Expand All @@ -62,13 +62,13 @@ var _ = PDescribe("[expansion] Test expanding/shrinking an existing cluster flee
nonGatewayNodes := framework.FindNonGatewayNodes(framework.ClusterC)
Expect(nonGatewayNodes).ToNot(BeEmpty(), fmt.Sprintf("No non-gateway nodes found on %q", clusterCName))
nonGatewayNode := nonGatewayNodes[0].Name
By(fmt.Sprintf("Adding cluster %q by setting the gateway label on node %q", clusterCName, nonGatewayNode))
framework.By(fmt.Sprintf("Adding cluster %q by setting the gateway label on node %q", clusterCName, nonGatewayNode))
f.SetGatewayLabelOnNode(context.TODO(), framework.ClusterC, nonGatewayNode, true)

gatewayPod := f.AwaitSubmarinerGatewayPod(framework.ClusterC)
By(fmt.Sprintf("Found submariner gateway pod %q on %q", gatewayPod.Name, clusterCName))
framework.By(fmt.Sprintf("Found submariner gateway pod %q on %q", gatewayPod.Name, clusterCName))

By("Checking connectivity between clusters")
framework.By("Checking connectivity between clusters")
tcp.RunConnectivityTest(tcp.ConnectivityTestParams{
Framework: f,
FromCluster: framework.ClusterB,
Expand All @@ -86,12 +86,12 @@ var _ = PDescribe("[expansion] Test expanding/shrinking an existing cluster flee
ToClusterScheduling: framework.NonGatewayNode,
})

By(fmt.Sprintf("Removing cluster %q by unsetting the gateway label and deleting submariner gateway pod %q",
framework.By(fmt.Sprintf("Removing cluster %q by unsetting the gateway label and deleting submariner gateway pod %q",
clusterCName, gatewayPod.Name))
f.SetGatewayLabelOnNode(context.TODO(), framework.ClusterC, nonGatewayNode, false)
f.DeletePod(framework.ClusterC, gatewayPod.Name, framework.TestContext.SubmarinerNamespace)

By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a service in cluster %q", clusterAName, clusterCName))
framework.By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a service in cluster %q", clusterAName, clusterCName))
tcp.RunNoConnectivityTest(tcp.ConnectivityTestParams{
Framework: f,
FromCluster: framework.ClusterA,
Expand All @@ -100,7 +100,7 @@ var _ = PDescribe("[expansion] Test expanding/shrinking an existing cluster flee
ToClusterScheduling: framework.NonGatewayNode,
})

By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a pod in cluster %q", clusterBName, clusterCName))
framework.By(fmt.Sprintf("Verifying that a pod in cluster %q cannot connect to a pod in cluster %q", clusterBName, clusterCName))
tcp.RunNoConnectivityTest(tcp.ConnectivityTestParams{
Framework: f,
ToEndpointType: tcp.ServiceIP,
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/compliance/fips.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("FIPS", Label(TestLabel), func() {
})

func testFIPSGatewayStatus(f *subFramework.Framework) {
By(fmt.Sprintln("Find a cluster with FIPS enabled"))
framework.By(fmt.Sprintln("Find a cluster with FIPS enabled"))

fipsCluster := f.FindFIPSEnabledCluster()

Expand All @@ -49,15 +49,15 @@ func testFIPSGatewayStatus(f *subFramework.Framework) {
}

fipsClusterName := framework.TestContext.ClusterIDs[fipsCluster]
By(fmt.Sprintf("Found enabled FIPS on cluster %q", fipsClusterName))
framework.By(fmt.Sprintf("Found enabled FIPS on cluster %q", fipsClusterName))

submEndpoint := f.AwaitSubmarinerEndpoint(fipsCluster, subFramework.NoopCheckEndpoint)

if submEndpoint.Spec.Backend != "libreswan" {
framework.Skipf(fmt.Sprintf("Cluster %q is not using the libreswan cable driver, skipping the test...", fipsClusterName))
}

By(fmt.Sprintf("Locate active gateway pod on cluster %q", fipsClusterName))
framework.By(fmt.Sprintf("Locate active gateway pod on cluster %q", fipsClusterName))

gwPod := f.AwaitActiveGatewayPod(fipsCluster, nil)
Expect(gwPod).ToNot(BeNil(), "Did not find an active gateway pod")
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/dataplane/gateway_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ var _ = Describe("Gateway status reporting", Label(TestLabel), func() {
It("should correctly report its status and connection information", func() {
clusterAName := framework.TestContext.ClusterIDs[framework.ClusterA]

By(fmt.Sprintf("Ensuring that only one gateway reports as active on %q", clusterAName))
framework.By(fmt.Sprintf("Ensuring that only one gateway reports as active on %q", clusterAName))

activeGateways := f.AwaitGatewaysWithStatus(framework.ClusterA, submarinerv1.HAStatusActive)
Expect(activeGateways).To(HaveLen(1))

name := activeGateways[0].Name
otherCluster := framework.TestContext.ClusterIDs[framework.ClusterB]

By(fmt.Sprintf("Ensuring that gateway %q reports connection information for cluster %q", name, otherCluster))
framework.By(fmt.Sprintf("Ensuring that gateway %q reports connection information for cluster %q", name, otherCluster))

gwClient := subFramework.SubmarinerClients[framework.ClusterA].SubmarinerV1().Gateways(
framework.TestContext.SubmarinerNamespace)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/dataplane/tcp_gn_pod_connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var _ = Describe("Basic TCP connectivity tests across overlapping clusters witho
lpConfig.Port++
cpConfig.Port = lpConfig.Port

By(fmt.Sprintf("Updating service port to %d", lpConfig.Port))
framework.By(fmt.Sprintf("Updating service port to %d", lpConfig.Port))

err := util.Update(context.Background(), resource.ForService(framework.KubeClients[lpConfig.Cluster],
f.Namespace), service, func(existing *v1.Service) (*v1.Service, error) {
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/framework/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func verifyGlobalnetDatapathConnectivity(p tcp.ConnectivityTestParams, gn Global

Expect(connectorPodGlobalIPs).ToNot(BeEmpty())

By(fmt.Sprintf("Creating a listener pod in cluster %q, which will wait for a handshake over TCP",
framework.By(fmt.Sprintf("Creating a listener pod in cluster %q, which will wait for a handshake over TCP",
framework.TestContext.ClusterIDs[p.ToCluster]))

listenerPodConfig := &framework.NetworkPodConfig{
Expand All @@ -128,7 +128,7 @@ func verifyGlobalnetDatapathConnectivity(p tcp.ConnectivityTestParams, gn Global

listenerPod := p.Framework.NewNetworkPod(listenerPodConfig)

By(fmt.Sprintf("Pointing a ClusterIP service to the listener pod in cluster %q",
framework.By(fmt.Sprintf("Pointing a ClusterIP service to the listener pod in cluster %q",
framework.TestContext.ClusterIDs[p.ToCluster]))

var service *v1.Service
Expand All @@ -144,7 +144,7 @@ func verifyGlobalnetDatapathConnectivity(p tcp.ConnectivityTestParams, gn Global
remoteIP := getGlobalIngressIP(p, service)
Expect(remoteIP).ToNot(Equal(""))

By(fmt.Sprintf("Creating a connector pod in cluster %q, which will attempt the specific UUID handshake over TCP",
framework.By(fmt.Sprintf("Creating a connector pod in cluster %q, which will attempt the specific UUID handshake over TCP",
framework.TestContext.ClusterIDs[p.FromCluster]))

connectorPodConfig := &framework.NetworkPodConfig{
Expand Down Expand Up @@ -177,19 +177,19 @@ func verifyGlobalnetDatapathConnectivity(p tcp.ConnectivityTestParams, gn Global
}, connector.Config.Cluster)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("Connector pod is scheduled on node %q", connector.Pod.Spec.NodeName))
framework.By(fmt.Sprintf("Connector pod is scheduled on node %q", connector.Pod.Spec.NodeName))

By(fmt.Sprintf("Waiting for the listener pod %q on node %q to exit, returning what listener sent",
framework.By(fmt.Sprintf("Waiting for the listener pod %q on node %q to exit, returning what listener sent",
listener.Pod.Name, listener.Pod.Spec.NodeName))
listener.AwaitFinish()
listener.CheckSuccessfulFinish()
p.Framework.DeletePod(p.FromCluster, connector.Pod.Name, connector.Pod.Namespace)

By("Verifying that the listener got the connector's data and the connector got the listener's data")
framework.By("Verifying that the listener got the connector's data and the connector got the listener's data")
Expect(listener.TerminationMessage).To(ContainSubstring(connector.Config.Data))
Expect(stdOut).To(ContainSubstring(listener.Config.Data))

By(fmt.Sprintf("Verifying the output of the listener pod contains a %s global IP %v of the connector Pod",
framework.By(fmt.Sprintf("Verifying the output of the listener pod contains a %s global IP %v of the connector Pod",
gn.GlobalEgressIP, connectorPodGlobalIPs))

matchIP := ContainSubstring(connectorPodGlobalIPs[0])
Expand Down
42 changes: 21 additions & 21 deletions test/e2e/redundancy/gateway_failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var _ = Describe("Gateway fail-over tests", Label(TestLabel), func() {
})

func testGatewayPodRestartScenario(f *subFramework.Framework) {
By(fmt.Sprintln("Sanity check - find a cluster with only one gateway node"))
framework.By(fmt.Sprintln("Sanity check - find a cluster with only one gateway node"))

primaryCluster := subFramework.FindClusterWithSingleGateway()
if primaryCluster == -1 {
Expand All @@ -72,33 +72,33 @@ func testGatewayPodRestartScenario(f *subFramework.Framework) {
primaryClusterName := framework.TestContext.ClusterIDs[primaryCluster]
secondaryClusterName := framework.TestContext.ClusterIDs[secondaryCluster]

By(fmt.Sprintf("Detected primary cluster %q with single gateway node", primaryClusterName))
By(fmt.Sprintf("Detected secondary cluster %q", secondaryClusterName))
framework.By(fmt.Sprintf("Detected primary cluster %q with single gateway node", primaryClusterName))
framework.By(fmt.Sprintf("Detected secondary cluster %q", secondaryClusterName))

gatewayNodes := framework.FindGatewayNodes(primaryCluster)
Expect(gatewayNodes).To(HaveLen(1), fmt.Sprintf("Expected only one gateway node on %q", primaryClusterName))
By(fmt.Sprintf("Found gateway on node %q on %q", gatewayNodes[0].Name, primaryClusterName))
framework.By(fmt.Sprintf("Found gateway on node %q on %q", gatewayNodes[0].Name, primaryClusterName))

gatewayPod := f.AwaitSubmarinerGatewayPod(primaryCluster)
By(fmt.Sprintf("Found submariner gateway pod %q on %q, checking node and HA status labels", gatewayPod.Name, primaryClusterName))
framework.By(fmt.Sprintf("Found submariner gateway pod %q on %q, checking node and HA status labels", gatewayPod.Name, primaryClusterName))

Expect(gatewayPod.Labels[gatewayStatusLabel]).To(Equal(gatewayStatusActive))
Expect(gatewayPod.Labels[gatewayNodeLabel]).To(Equal(gatewayNodes[0].Name))

By(fmt.Sprintf("Ensuring that the gateway reports as active on %q", primaryClusterName))
framework.By(fmt.Sprintf("Ensuring that the gateway reports as active on %q", primaryClusterName))

activeGateway := f.AwaitGatewayFullyConnected(primaryCluster, resource.EnsureValidName(gatewayNodes[0].Name))

By(fmt.Sprintf("Deleting submariner gateway pod %q", gatewayPod.Name))
framework.By(fmt.Sprintf("Deleting submariner gateway pod %q", gatewayPod.Name))
f.DeletePod(primaryCluster, gatewayPod.Name, framework.TestContext.SubmarinerNamespace)

newGatewayPod := AwaitNewSubmarinerGatewayPod(f, primaryCluster, gatewayPod.ObjectMeta.UID)
By(fmt.Sprintf("Found new submariner gateway pod %q", newGatewayPod.Name))
framework.By(fmt.Sprintf("Found new submariner gateway pod %q", newGatewayPod.Name))

By(fmt.Sprintf("Waiting for the gateway to be up and connected %q", newGatewayPod.Name))
framework.By(fmt.Sprintf("Waiting for the gateway to be up and connected %q", newGatewayPod.Name))
AwaitNewSubmarinerGatewayFullyConnected(f, primaryCluster, activeGateway.Name, activeGateway.UID)

By(fmt.Sprintf("Verifying TCP connectivity from gateway node on %q to gateway node on %q", secondaryClusterName, primaryClusterName))
framework.By(fmt.Sprintf("Verifying TCP connectivity from gateway node on %q to gateway node on %q", secondaryClusterName, primaryClusterName))
subFramework.VerifyDatapathConnectivity(tcp.ConnectivityTestParams{
Framework: f.Framework,
FromCluster: secondaryCluster,
Expand All @@ -113,7 +113,7 @@ func testGatewayPodRestartScenario(f *subFramework.Framework) {
return
}

By(fmt.Sprintf("Verifying TCP connectivity from non-gateway node on %q to non-gateway node on %q",
framework.By(fmt.Sprintf("Verifying TCP connectivity from non-gateway node on %q to non-gateway node on %q",
secondaryClusterName, primaryClusterName))
subFramework.VerifyDatapathConnectivity(tcp.ConnectivityTestParams{
Framework: f.Framework,
Expand Down Expand Up @@ -175,40 +175,40 @@ func testGatewayFailOverScenario(f *subFramework.Framework) {
clusterAName := framework.TestContext.ClusterIDs[primaryCluster]
clusterBName := framework.TestContext.ClusterIDs[secondaryCluster]

By(fmt.Sprintf("Found two gateway nodes on %q", clusterAName))
framework.By(fmt.Sprintf("Found two gateway nodes on %q", clusterAName))

initialGWPod := f.AwaitActiveGatewayPod(framework.ClusterIndex(primaryCluster), nil)
Expect(initialGWPod).ToNot(BeNil(), "Did not find an active gateway pod")

By(fmt.Sprintf("Ensure active gateway node %q has established connections", initialGWPod.Name))
framework.By(fmt.Sprintf("Ensure active gateway node %q has established connections", initialGWPod.Name))
gwConnection := f.AwaitGatewayWithStatus(framework.ClusterIndex(primaryCluster), initialGWPod.Spec.NodeName, subv1.HAStatusActive)
Expect(gwConnection.Status.Connections).NotTo(BeEmpty(), "The active gateway must have established connections")

submEndpoint := f.AwaitSubmarinerEndpoint(framework.ClusterIndex(primaryCluster), subFramework.NoopCheckEndpoint)
By(fmt.Sprintf("Found submariner endpoint for %q: %#v", clusterAName, submEndpoint))
framework.By(fmt.Sprintf("Found submariner endpoint for %q: %#v", clusterAName, submEndpoint))

By("Performing fail-over to passive gateway")
framework.By("Performing fail-over to passive gateway")
f.DoFailover(context.TODO(), framework.ClusterIndex(primaryCluster), initialGWPod.Spec.NodeName, initialGWPod.Name)

newGWPod := f.AwaitActiveGatewayPod(framework.ClusterIndex(primaryCluster), func(pod *v1.Pod) bool {
return pod.Spec.NodeName != initialGWPod.Spec.NodeName
})

Expect(newGWPod).ToNot(BeNil(), "Did not find a new active gateway pod running on a different node")
By(fmt.Sprintf("Found new submariner gateway pod %q", newGWPod.Name))
framework.By(fmt.Sprintf("Found new submariner gateway pod %q", newGWPod.Name))

By(fmt.Sprintf("Waiting for the new pod %q to report as fully connected", newGWPod.Name))
framework.By(fmt.Sprintf("Waiting for the new pod %q to report as fully connected", newGWPod.Name))
f.AwaitGatewayFullyConnected(framework.ClusterIndex(primaryCluster), resource.EnsureValidName(newGWPod.Spec.NodeName))

// Verify a new Endpoint instance is created by the new gateway instance. This is a bit whitebox but it's a sanity check
// and also gives it a bit more of a cushion to avoid premature timeout in the connectivity test.
newSubmEndpoint := f.AwaitNewSubmarinerEndpoint(framework.ClusterIndex(primaryCluster), submEndpoint.ObjectMeta.UID)
By(fmt.Sprintf("Found new submariner endpoint for %q: %#v", clusterAName, newSubmEndpoint))
framework.By(fmt.Sprintf("Found new submariner endpoint for %q: %#v", clusterAName, newSubmEndpoint))

By(fmt.Sprintf("Waiting for the previous submariner endpoint %q to be removed on %q", newGWPod.Name, clusterBName))
framework.By(fmt.Sprintf("Waiting for the previous submariner endpoint %q to be removed on %q", newGWPod.Name, clusterBName))
f.AwaitSubmarinerEndpointRemoved(framework.ClusterIndex(secondaryCluster), submEndpoint.Name)

By(fmt.Sprintf("Verifying TCP connectivity from gateway node on %q to gateway node on %q", clusterBName, clusterAName))
framework.By(fmt.Sprintf("Verifying TCP connectivity from gateway node on %q to gateway node on %q", clusterBName, clusterAName))
subFramework.VerifyDatapathConnectivity(tcp.ConnectivityTestParams{
Framework: f.Framework,
FromCluster: framework.ClusterIndex(secondaryCluster),
Expand All @@ -223,7 +223,7 @@ func testGatewayFailOverScenario(f *subFramework.Framework) {
return
}

By(fmt.Sprintf("Verifying TCP connectivity from non-gateway node on %q to non-gateway node on %q", clusterBName, clusterAName))
framework.By(fmt.Sprintf("Verifying TCP connectivity from non-gateway node on %q to non-gateway node on %q", clusterBName, clusterAName))
subFramework.VerifyDatapathConnectivity(tcp.ConnectivityTestParams{
Framework: f.Framework,
FromCluster: framework.ClusterIndex(secondaryCluster),
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/redundancy/leader_election.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ var _ = Describe("Leader election tests", func() {

gateway := f.AwaitGatewayWithStatus(cluster, gatewayPod.Spec.NodeName, subv1.HAStatusActive)

By(fmt.Sprintf("Found submariner Gateway %q on cluster %q", gateway.Name, clusterName))
framework.By(fmt.Sprintf("Found submariner Gateway %q on cluster %q", gateway.Name, clusterName))

By("Updating submariner-gateway Role to remove Lease update permission")
framework.By("Updating submariner-gateway Role to remove Lease update permission")

updateLeaseUpdatePermission(cluster, gateway.Namespace, slices.Remove[string, string])

DeferCleanup(func() {
updateLeaseUpdatePermission(cluster, gateway.Namespace, slices.AppendIfNotPresent[string, string])
})

By(fmt.Sprintf("Ensure Gateway %q is updated to passive", gateway.Name))
framework.By(fmt.Sprintf("Ensure Gateway %q is updated to passive", gateway.Name))

f.AwaitGatewaysWithStatus(cluster, subv1.HAStatusPassive)

Expand All @@ -79,11 +79,11 @@ var _ = Describe("Leader election tests", func() {
Networking: framework.PodNetworking,
}, subFramework.GetGlobalnetEgressParams(subFramework.ClusterSelector))

By("Updating submariner-gateway Role to add Lease update permission")
framework.By("Updating submariner-gateway Role to add Lease update permission")

updateLeaseUpdatePermission(cluster, gateway.Namespace, slices.AppendIfNotPresent[string, string])

By(fmt.Sprintf("Ensure Gateway %q is updated to active", gateway.Name))
framework.By(fmt.Sprintf("Ensure Gateway %q is updated to active", gateway.Name))

f.AwaitGatewayWithStatus(cluster, gatewayPod.Spec.NodeName, subv1.HAStatusActive)

Expand Down
Loading

0 comments on commit eb536b4

Please sign in to comment.