Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
tests(e2e): configure ports to make e2es pass on OpenShift
Browse files Browse the repository at this point in the history
Signed-off-by: Sanya Kochhar <[email protected]>
  • Loading branch information
SanyaKochhar committed Jul 14, 2021
1 parent 32b9a78 commit 0be61da
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
6 changes: 0 additions & 6 deletions tests/e2e/constants.go

This file was deleted.

7 changes: 4 additions & 3 deletions tests/e2e/e2e_deployment_client_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ var _ = OSMDescribe("Test HTTP traffic from N deployment client -> 1 deployment
Namespace: destApp,
ReplicaCount: int32(replicaSetPerService),
Image: "kennethreitz/httpbin",
Ports: []int{80},
Ports: []int{DefaultUpstreamServicePort},
Command: HttpbinCmd,
})

_, err := Td.CreateServiceAccount(destApp, &svcAccDef)
Expand All @@ -85,7 +86,7 @@ var _ = OSMDescribe("Test HTTP traffic from N deployment client -> 1 deployment
Command: []string{"/bin/bash", "-c", "--"},
Args: []string{"while true; do sleep 30; done;"},
Image: "songrgg/alpine-debug",
Ports: []int{80}, // Can't deploy services with empty/no ports
Ports: []int{DefaultUpstreamServicePort}, // Can't deploy services with empty/no ports
})
_, err = Td.CreateServiceAccount(srcClient, &svcAccDef)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -139,7 +140,7 @@ var _ = OSMDescribe("Test HTTP traffic from N deployment client -> 1 deployment
SourcePod: pod.Name,
SourceContainer: ns, // container_name == NS for this test

Destination: fmt.Sprintf("%s.%s", destApp, destApp),
Destination: fmt.Sprintf("%s.%s:%d", destApp, destApp, DefaultUpstreamServicePort),
})
}
}
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/e2e_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ var _ = OSMDescribe("Custom WASM metrics between one client pod and one server",
Name: "server",
Namespace: destNs,
Image: "kennethreitz/httpbin",
Ports: []int{80},
Ports: []int{DefaultUpstreamServicePort},
Command: HttpbinCmd,
})

_, err = Td.CreateServiceAccount(destNs, &svcAccDef)
Expand All @@ -76,7 +77,7 @@ var _ = OSMDescribe("Custom WASM metrics between one client pod and one server",
Command: []string{"/bin/bash", "-c", "--"},
Args: []string{"while true; do sleep 30; done;"},
Image: "songrgg/alpine-debug",
Ports: []int{80},
Ports: []int{DefaultUpstreamServicePort},
})

_, err = Td.CreateServiceAccount(sourceNs, &svcAccDef)
Expand Down Expand Up @@ -120,7 +121,7 @@ var _ = OSMDescribe("Custom WASM metrics between one client pod and one server",
SourcePod: srcPod.Name,
SourceContainer: "client",

Destination: fmt.Sprintf("%s.%s/status/200", dstSvc.Name, dstSvc.Namespace),
Destination: fmt.Sprintf("%s.%s:%d/status/200", dstSvc.Name, dstSvc.Namespace, DefaultUpstreamServicePort),
})

if result.Err != nil || result.StatusCode != 200 {
Expand Down
13 changes: 6 additions & 7 deletions tests/e2e/e2e_trafficsplit_recursive_split.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ func testRecursiveTrafficSplit(appProtocol string) {
const (
// to name the header we will use to identify the server that replies
HTTPHeaderName = "podname"

serverPort = 80
)

clientAppBaseName := "client"
Expand Down Expand Up @@ -80,8 +78,9 @@ func testRecursiveTrafficSplit(appProtocol string) {
Namespace: serverNamespace,
ReplicaCount: int32(serverReplicaSet),
Image: "simonkowallik/httpbin",
Ports: []int{serverPort},
Ports: []int{DefaultUpstreamServicePort},
AppProtocol: appProtocol,
Command: HttpbinCmd,
})

// Expose an env variable such as XHTTPBIN_X_POD_NAME:
Expand Down Expand Up @@ -123,7 +122,7 @@ func testRecursiveTrafficSplit(appProtocol string) {
Command: []string{"/bin/bash", "-c", "--"},
Args: []string{"while true; do sleep 30; done;"},
Image: "songrgg/alpine-debug",
Ports: []int{80},
Ports: []int{DefaultUpstreamServicePort},
})

_, err := Td.CreateServiceAccount(clientApp, &svcAccDef)
Expand Down Expand Up @@ -201,7 +200,7 @@ func testRecursiveTrafficSplit(appProtocol string) {
DestinationNamespace: serverNamespace,
DestinationSvcAccountName: dstServer,
},
serverPort,
DefaultUpstreamServicePort,
)

// Configs have to be put into same NS as server/destination
Expand Down Expand Up @@ -234,7 +233,7 @@ func testRecursiveTrafficSplit(appProtocol string) {
SourceContainer: ns, // container_name == NS for this test

// Targeting the trafficsplit FQDN
Destination: fmt.Sprintf("%s.%s", trafficSplitName, serverNamespace),
Destination: fmt.Sprintf("%s.%s:%d", trafficSplitName, serverNamespace, DefaultUpstreamServicePort),
})
}
}
Expand Down Expand Up @@ -295,7 +294,7 @@ func testRecursiveTrafficSplit(appProtocol string) {
SourceContainer: pod.Namespace, // We generally code it like so for test purposes

// direct traffic target against the specific server service in the server namespace
Destination: fmt.Sprintf("%s.%s", svcNs, serverNamespace),
Destination: fmt.Sprintf("%s.%s:%d", svcNs, serverNamespace, DefaultUpstreamServicePort),
})
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/e2e_trafficsplit_same_sa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ var _ = OSMDescribe("Test TrafficSplit where each backend shares the same Servic
Namespace: serverNamespace,
ReplicaCount: int32(serverReplicaSet),
Image: "simonkowallik/httpbin",
Ports: []int{appPort},
Command: []string{"gunicorn", "-b", fmt.Sprintf("0.0.0.0:%d", appPort), "httpbin:app", "-k", "gevent"},
Ports: []int{DefaultUpstreamServicePort},
Command: HttpbinCmd,
})

// Expose an env variable such as XHTTPBIN_X_POD_NAME:
Expand Down Expand Up @@ -122,7 +122,7 @@ var _ = OSMDescribe("Test TrafficSplit where each backend shares the same Servic
Command: []string{"/bin/bash", "-c", "--"},
Args: []string{"while true; do sleep 30; done;"},
Image: "songrgg/alpine-debug",
Ports: []int{appPort},
Ports: []int{DefaultUpstreamServicePort},
})

_, err := Td.CreateServiceAccount(clientApp, &svcAccDef)
Expand Down Expand Up @@ -165,7 +165,7 @@ var _ = OSMDescribe("Test TrafficSplit where each backend shares the same Servic
_, _, trafficSplitService := Td.SimplePodApp(SimplePodAppDef{
Name: trafficSplitName,
Namespace: serverNamespace,
Ports: []int{appPort},
Ports: []int{DefaultUpstreamServicePort},
})

// Creating trafficsplit service in K8s
Expand Down Expand Up @@ -212,7 +212,7 @@ var _ = OSMDescribe("Test TrafficSplit where each backend shares the same Servic
SourceContainer: ns, // container_name == NS for this test

// Targeting the trafficsplit FQDN
Destination: fmt.Sprintf("%s.%s:%d", trafficSplitName, serverNamespace, appPort),
Destination: fmt.Sprintf("%s.%s:%d", trafficSplitName, serverNamespace, DefaultUpstreamServicePort),
})
}
}
Expand Down
15 changes: 7 additions & 8 deletions tests/e2e/e2e_trafficsplit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ func testTrafficSplit(appProtocol string) {
const (
// to name the header we will use to identify the server that replies
HTTPHeaderName = "podname"

serverPort = 80
)

clientAppBaseName := "client"
Expand Down Expand Up @@ -85,8 +83,9 @@ func testTrafficSplit(appProtocol string) {
Namespace: serverNamespace,
ReplicaCount: int32(serverReplicaSet),
Image: "simonkowallik/httpbin",
Ports: []int{serverPort},
Ports: []int{DefaultUpstreamServicePort},
AppProtocol: appProtocol,
Command: HttpbinCmd,
})

// Expose an env variable such as XHTTPBIN_X_POD_NAME:
Expand Down Expand Up @@ -128,7 +127,7 @@ func testTrafficSplit(appProtocol string) {
Command: []string{"/bin/bash", "-c", "--"},
Args: []string{"while true; do sleep 30; done;"},
Image: "songrgg/alpine-debug",
Ports: []int{80},
Ports: []int{DefaultUpstreamServicePort},
})

_, err := Td.CreateServiceAccount(clientApp, &svcAccDef)
Expand Down Expand Up @@ -184,7 +183,7 @@ func testTrafficSplit(appProtocol string) {
DestinationNamespace: serverNamespace,
DestinationSvcAccountName: dstServer,
},
serverPort,
DefaultUpstreamServicePort,
)

// Configs have to be put into a monitored NS
Expand All @@ -203,7 +202,7 @@ func testTrafficSplit(appProtocol string) {
_, _, trafficSplitService := Td.SimplePodApp(SimplePodAppDef{
Name: trafficSplitName,
Namespace: serverNamespace,
Ports: []int{80},
Ports: []int{DefaultUpstreamServicePort},
AppProtocol: appProtocol,
})

Expand Down Expand Up @@ -253,7 +252,7 @@ func testTrafficSplit(appProtocol string) {
SourceContainer: ns, // container_name == NS for this test

// Targeting the trafficsplit FQDN
Destination: fmt.Sprintf("%s.%s", trafficSplitName, serverNamespace),
Destination: fmt.Sprintf("%s.%s:%d", trafficSplitName, serverNamespace, DefaultUpstreamServicePort),
})
}
}
Expand Down Expand Up @@ -314,7 +313,7 @@ func testTrafficSplit(appProtocol string) {
SourceContainer: pod.Namespace, // We generally code it like so for test purposes

// direct traffic target against the specific server service in the server namespace
Destination: fmt.Sprintf("%s.%s", svcNs, serverNamespace),
Destination: fmt.Sprintf("%s.%s:%d", svcNs, serverNamespace, DefaultUpstreamServicePort),
})
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/framework/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ func OSMDescribe(name string, opts OSMDescribeInfo, body func()) bool {
return Describe(fmt.Sprintf("%s %s", opts, name), body)
}

const (
// DefaultUpstreamServicePort is the default port on which the server apps listen for connections from client apps.
// Note: Port 80 should not be used because it does not work on OpenShift.
DefaultUpstreamServicePort = 14001
)

// HttpbinCmd is the command to be used for httpbin applications in e2es
var HttpbinCmd = []string{"gunicorn", "-b", fmt.Sprintf("0.0.0.0:%d", DefaultUpstreamServicePort), "httpbin:app", "-k", "gevent"}

// Verifies the instType string flag option is a valid enum type
func verifyValidInstallType(t InstallType) error {
switch t {
Expand Down

0 comments on commit 0be61da

Please sign in to comment.