Skip to content

Commit bc1c825

Browse files
committed
Switched from toxiproxy cli to toxiproxy API. Requesting listen on port 0 to more reliably obtain an unused local port.
1 parent 59ae344 commit bc1c825

File tree

4 files changed

+95
-118
lines changed

4 files changed

+95
-118
lines changed

test/e2e/deploy_app_toxi.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ func DeployAppToxiSpec(ctx context.Context, inputGetter func() CommonSpecInput)
4040
namespace *corev1.Namespace
4141
cancelWatches context.CancelFunc
4242
clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult
43-
appName = "httpd"
44-
appManifestPath = "data/fixture/sample-application.yaml"
45-
expectedHtmlPath = "data/fixture/expected-webpage.html"
46-
appDeploymentReadyTimeout = 180
47-
appPort = 8080
48-
appDefaultHtmlPath = "/"
49-
expectedHtml = ""
50-
toxiProxy *helpers.ToxiProxy = nil
43+
appName = "httpd"
44+
appManifestPath = "data/fixture/sample-application.yaml"
45+
expectedHtmlPath = "data/fixture/expected-webpage.html"
46+
appDeploymentReadyTimeout = 180
47+
appPort = 8080
48+
appDefaultHtmlPath = "/"
49+
expectedHtml = ""
50+
toxiProxyContext *helpers.ToxiProxyContext = nil
5151
toxicName string
5252
)
5353

@@ -64,7 +64,7 @@ func DeployAppToxiSpec(ctx context.Context, inputGetter func() CommonSpecInput)
6464
Expect(input.E2EConfig.Variables).To(HaveKey(KubernetesVersion))
6565

6666
// Setup a toxiProxy for this test.
67-
toxiProxy := helpers.SetupForToxiproxyTesting(ctx, input.BootstrapClusterProxy)
67+
toxiProxy := helpers.SetupForToxiproxyTesting(input.BootstrapClusterProxy)
6868
toxicName = toxiProxy.AddLatencyToxic(100, 10, 100, false)
6969

7070
// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events.
@@ -87,12 +87,12 @@ func DeployAppToxiSpec(ctx context.Context, inputGetter func() CommonSpecInput)
8787
clusterName := fmt.Sprintf("%s-%s", specName, util.RandomString(6))
8888

8989
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
90-
ClusterProxy: toxiProxy.ClusterProxy,
90+
ClusterProxy: toxiProxyContext.ClusterProxy,
9191
CNIManifestPath: input.E2EConfig.GetVariable(CNIPath),
9292
ConfigCluster: clusterctl.ConfigClusterInput{
93-
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", toxiProxy.ClusterProxy.GetName()),
93+
LogFolder: filepath.Join(input.ArtifactFolder, "clusters", toxiProxyContext.ClusterProxy.GetName()),
9494
ClusterctlConfigPath: input.ClusterctlConfigPath,
95-
KubeconfigPath: toxiProxy.ClusterProxy.GetKubeconfigPath(),
95+
KubeconfigPath: toxiProxyContext.ClusterProxy.GetKubeconfigPath(),
9696
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
9797
Flavor: flavor,
9898
Namespace: namespace,
@@ -106,7 +106,7 @@ func DeployAppToxiSpec(ctx context.Context, inputGetter func() CommonSpecInput)
106106
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
107107
}, clusterResources)
108108

109-
workloadClusterProxy := toxiProxy.ClusterProxy.GetWorkloadCluster(ctx, namespace, clusterName)
109+
workloadClusterProxy := toxiProxyContext.ClusterProxy.GetWorkloadCluster(ctx, namespace, clusterName)
110110
workloadKubeconfigPath := workloadClusterProxy.GetKubeconfigPath()
111111

112112
appManifestAbsolutePath, _ := filepath.Abs(appManifestPath)
@@ -136,10 +136,10 @@ func DeployAppToxiSpec(ctx context.Context, inputGetter func() CommonSpecInput)
136136

137137
AfterEach(func() {
138138
// Dumps all the resources in the spec namespace, then cleanups the cluster object and the spec namespace itself.
139-
dumpSpecResourcesAndCleanup(ctx, specName, toxiProxy.ClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup)
139+
dumpSpecResourcesAndCleanup(ctx, specName, toxiProxyContext.ClusterProxy, input.ArtifactFolder, namespace, cancelWatches, clusterResources.Cluster, input.E2EConfig.GetIntervals, input.SkipCleanup)
140140

141141
// Tear down the proxy
142-
toxiProxy.RemoveToxic(toxicName)
143-
helpers.TearDownToxiProxy(ctx, toxiProxy)
142+
toxiProxyContext.RemoveToxic(toxicName)
143+
helpers.TearDownToxiProxy(toxiProxyContext)
144144
})
145145
}

test/e2e/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module sigs.k8s.io/cluster-api-provider-cloudstack-staging/test/e2e
33
go 1.16
44

55
require (
6+
github.com/Shopify/toxiproxy/v2 v2.5.0
67
github.com/apache/cloudstack-go/v2 v2.12.0
78
github.com/blang/semver v3.5.1+incompatible
89
github.com/onsi/ginkgo v1.16.5
910
github.com/onsi/gomega v1.17.0
10-
gopkg.in/ini.v1 v1.63.2
11-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
11+
gopkg.in/yaml.v3 v3.0.1
1212
k8s.io/api v0.23.0
1313
k8s.io/apimachinery v0.23.0
1414
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b

0 commit comments

Comments
 (0)