Skip to content

Commit

Permalink
E2E: make connection timeout configurable (submariner-io#268)
Browse files Browse the repository at this point in the history
* E2E: make connection timeout configurable

Added 'connection-timeout' and `connection-attempts' test params.
Defaults are 6 and 10 for total timeout of 60 s.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>

* E2E: make timeout used by AwaitResultOrError configurable

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
  • Loading branch information
tpantelis authored Dec 24, 2019
1 parent ccf01eb commit 06332b9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
29 changes: 17 additions & 12 deletions test/e2e/dataplane/tcp_pod_connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ var _ = Describe("[dataplane] Basic TCP connectivity tests across clusters witho

func RunConnectivityTest(f *framework.Framework, useService bool, listenerScheduling framework.NetworkPodScheduling, connectorScheduling framework.NetworkPodScheduling, listenerCluster framework.ClusterIndex, connectorCluster framework.ClusterIndex) (*framework.NetworkPod, *framework.NetworkPod) {

listenerPod, connectorPod := createPods(f, useService, listenerScheduling, connectorScheduling, listenerCluster, connectorCluster, 45)
listenerPod, connectorPod := createPods(f, useService, listenerScheduling, connectorScheduling, listenerCluster, connectorCluster,
framework.TestContext.ConnectionTimeout, framework.TestContext.ConnectionAttempts)
listenerPod.CheckSuccessfulFinish()
connectorPod.CheckSuccessfulFinish()

Expand All @@ -82,7 +83,7 @@ func RunConnectivityTest(f *framework.Framework, useService bool, listenerSchedu
}

func RunNoConnectivityTest(f *framework.Framework, useService bool, listenerScheduling framework.NetworkPodScheduling, connectorScheduling framework.NetworkPodScheduling, listenerCluster framework.ClusterIndex, connectorCluster framework.ClusterIndex) (*framework.NetworkPod, *framework.NetworkPod) {
listenerPod, connectorPod := createPods(f, useService, listenerScheduling, connectorScheduling, listenerCluster, connectorCluster, 5)
listenerPod, connectorPod := createPods(f, useService, listenerScheduling, connectorScheduling, listenerCluster, connectorCluster, 5, 1)

By("Verifying that listener pod exits with non-zero code and timed out message")
Expect(listenerPod.TerminationMessage).To(ContainSubstring("nc: timeout"))
Expand All @@ -96,13 +97,16 @@ func RunNoConnectivityTest(f *framework.Framework, useService bool, listenerSche
return listenerPod, connectorPod
}

func createPods(f *framework.Framework, useService bool, listenerScheduling framework.NetworkPodScheduling, connectorScheduling framework.NetworkPodScheduling, listenerCluster framework.ClusterIndex, connectorCluster framework.ClusterIndex, connectionTimeout int) (*framework.NetworkPod, *framework.NetworkPod) {
func createPods(f *framework.Framework, useService bool, listenerScheduling framework.NetworkPodScheduling, connectorScheduling framework.NetworkPodScheduling, listenerCluster framework.ClusterIndex,
connectorCluster framework.ClusterIndex, connectionTimeout uint, connectionAttempts uint) (*framework.NetworkPod, *framework.NetworkPod) {

By(fmt.Sprintf("Creating a listener pod in cluster %q, which will wait for a handshake over TCP", framework.TestContext.KubeContexts[listenerCluster]))
listenerPod := f.NewNetworkPod(&framework.NetworkPodConfig{
Type: framework.ListenerPod,
Cluster: listenerCluster,
Scheduling: listenerScheduling,
ConnectionTimeout: connectionTimeout,
Type: framework.ListenerPod,
Cluster: listenerCluster,
Scheduling: listenerScheduling,
ConnectionTimeout: connectionTimeout,
ConnectionAttempts: connectionAttempts,
})

remoteIP := listenerPod.Pod.Status.PodIP
Expand All @@ -116,11 +120,12 @@ func createPods(f *framework.Framework, useService bool, listenerScheduling fram

By(fmt.Sprintf("Creating a connector pod in cluster %q, which will attempt the specific UUID handshake over TCP", framework.TestContext.KubeContexts[connectorCluster]))
connectorPod := f.NewNetworkPod(&framework.NetworkPodConfig{
Type: framework.ConnectorPod,
Cluster: connectorCluster,
Scheduling: connectorScheduling,
RemoteIP: remoteIP,
ConnectionTimeout: connectionTimeout,
Type: framework.ConnectorPod,
Cluster: connectorCluster,
Scheduling: connectorScheduling,
RemoteIP: remoteIP,
ConnectionTimeout: connectionTimeout,
ConnectionAttempts: connectionAttempts,
})

By(fmt.Sprintf("Waiting for the listener pod %q to exit, returning what listener sent", listenerPod.Pod.Name))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func AwaitUntil(opMsg string, doOperation DoOperationFunc, checkResult CheckResu
func AwaitResultOrError(opMsg string, doOperation DoOperationFunc, checkResult CheckResultFunc) (interface{}, string, error) {
var finalResult interface{}
var lastMsg string
err := wait.PollImmediate(5*time.Second, 1*time.Minute, func() (bool, error) {
err := wait.PollImmediate(5*time.Second, time.Duration(TestContext.OperationTimeout)*time.Second, func() (bool, error) {
result, err := doOperation()
if err != nil {
if IsTransientError(err, opMsg) {
Expand Down
22 changes: 11 additions & 11 deletions test/e2e/framework/network_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ const (
)

type NetworkPodConfig struct {
Type NetworkPodType
Cluster ClusterIndex
Scheduling NetworkPodScheduling
Port int
Data string
RemoteIP string
ConnectionTimeout int
Type NetworkPodType
Cluster ClusterIndex
Scheduling NetworkPodScheduling
Port int
Data string
RemoteIP string
ConnectionTimeout uint
ConnectionAttempts uint
// TODO: namespace, once https://github.com/submariner-io/submariner/pull/141 is merged
}

Expand Down Expand Up @@ -159,7 +160,7 @@ func (np *NetworkPod) buildTCPCheckListenerPod() {
Env: []v1.EnvVar{
{Name: "LISTEN_PORT", Value: strconv.Itoa(np.Config.Port)},
{Name: "SEND_STRING", Value: np.Config.Data},
{Name: "CONN_TIMEOUT", Value: strconv.Itoa(np.Config.ConnectionTimeout)},
{Name: "CONN_TIMEOUT", Value: strconv.Itoa(int(np.Config.ConnectionTimeout * np.Config.ConnectionAttempts))},
},
},
},
Expand All @@ -179,7 +180,6 @@ func (np *NetworkPod) buildTCPCheckListenerPod() {
// exit with 0 status
func (np *NetworkPod) buildTCPCheckConnectorPod() {

ncatConnectTimeout := 4 // seconds
tcpCheckConnectorPod := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "tcp-check-pod",
Expand All @@ -201,8 +201,8 @@ func (np *NetworkPod) buildTCPCheckConnectorPod() {
{Name: "REMOTE_PORT", Value: strconv.Itoa(np.Config.Port)},
{Name: "SEND_STRING", Value: np.Config.Data},
{Name: "REMOTE_IP", Value: np.Config.RemoteIP},
{Name: "CONN_TRIES", Value: strconv.Itoa(np.Config.ConnectionTimeout / ncatConnectTimeout)},
{Name: "CONN_TIMEOUT", Value: strconv.Itoa(ncatConnectTimeout)},
{Name: "CONN_TRIES", Value: strconv.Itoa(int(np.Config.ConnectionAttempts))},
{Name: "CONN_TIMEOUT", Value: strconv.Itoa(int(np.Config.ConnectionTimeout))},
},
},
},
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/framework/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type TestContextType struct {
ReportDir string
ReportPrefix string
SubmarinerNamespace string
ConnectionTimeout uint
ConnectionAttempts uint
OperationTimeout uint
}

func (contexts *contextArray) String() string {
Expand All @@ -36,6 +39,9 @@ func registerFlags(t *TestContextType) {
flag.StringVar(&TestContext.ReportPrefix, "report-prefix", "", "Optional prefix for JUnit XML reports. Default is empty, which doesn't prepend anything to the default name.")
flag.StringVar(&TestContext.ReportDir, "report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
flag.StringVar(&TestContext.SubmarinerNamespace, "submariner-namespace", "submariner", "Namespace in which the submariner components are deployed.")
flag.UintVar(&TestContext.ConnectionTimeout, "connection-timeout", 6, "The timeout in seconds per connection attempt when verifying communication between clusters.")
flag.UintVar(&TestContext.ConnectionAttempts, "connection-attempts", 10, "The number of connection attempts when verifying communication between clusters.")
flag.UintVar(&TestContext.OperationTimeout, "operation-timeout", 60, "The general operation timeout in seconds.")
}

func validateFlags(t *TestContextType) {
Expand Down

0 comments on commit 06332b9

Please sign in to comment.