Skip to content

Commit e33bdec

Browse files
committed
Renamings; bug fixes
1 parent bc1c825 commit e33bdec

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

test/e2e/deploy_app_toxi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ 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(input.BootstrapClusterProxy)
68-
toxicName = toxiProxy.AddLatencyToxic(100, 10, 100, false)
67+
toxiProxyContext = helpers.SetupForToxiproxyTesting(input.BootstrapClusterProxy)
68+
toxicName = toxiProxyContext.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.
71-
namespace, cancelWatches = setupSpecNamespace(ctx, specName, toxiProxy.ClusterProxy, input.ArtifactFolder)
71+
namespace, cancelWatches = setupSpecNamespace(ctx, specName, toxiProxyContext.ClusterProxy, input.ArtifactFolder)
7272
clusterResources = new(clusterctl.ApplyClusterTemplateAndWaitResult)
7373

7474
fileContent, err := os.ReadFile(expectedHtmlPath)

test/e2e/helpers/toxiProxy.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func ToxiProxyServerKill(ctx context.Context) error {
4141
type ToxiProxyContext struct {
4242
KubeconfigPath string
4343
ClusterProxy framework.ClusterProxy
44-
Proxy *toxiproxyapi.Proxy
44+
ToxiProxy *toxiproxyapi.Proxy
4545
}
4646

4747
func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *ToxiProxyContext {
@@ -59,6 +59,7 @@ func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *Tox
5959
serverRegex := regexp.MustCompilePOSIX("(https?)://([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+):([0-9]*)")
6060
urlComponents := serverRegex.FindStringSubmatch(server)
6161
Expect(len(urlComponents)).To(Equal(4))
62+
protocol := urlComponents[1]
6263
address := urlComponents[2]
6364
port, err := strconv.Atoi(urlComponents[3])
6465
Expect(err).To(BeNil())
@@ -74,7 +75,7 @@ func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *Tox
7475
Expect(err).To(BeNil())
7576

7677
// Get the actual listen address (having the toxiproxy-assigned port #).
77-
toxiProxyServerUrl := fmt.Sprintf("%v://%v", proxy.Listen)
78+
toxiProxyServerUrl := fmt.Sprintf("%v://%v", protocol, proxy.Listen)
7879

7980
// Modify the kubeconfig to use the toxiproxy's server url
8081
err = kubeConfig.SetCurrentServer(toxiProxyServerUrl)
@@ -94,13 +95,13 @@ func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *Tox
9495
return &ToxiProxyContext{
9596
KubeconfigPath: toxiProxyKubeconfigPath,
9697
ClusterProxy: toxiproxyBootstrapClusterProxy,
97-
Proxy: proxy,
98+
ToxiProxy: proxy,
9899
}
99100
}
100101

101102
func TearDownToxiProxy(toxiProxyContext *ToxiProxyContext) {
102103
// Tear down the proxy
103-
err := toxiProxyContext.Proxy.Delete()
104+
err := toxiProxyContext.ToxiProxy.Delete()
104105
Expect(err).To(BeNil())
105106

106107
// Delete the kubeconfig pointing to the proxy
@@ -110,7 +111,7 @@ func TearDownToxiProxy(toxiProxyContext *ToxiProxyContext) {
110111
}
111112

112113
func (tp *ToxiProxyContext) RemoveToxic(toxicName string) {
113-
err := tp.Proxy.RemoveToxic(toxicName)
114+
err := tp.ToxiProxy.RemoveToxic(toxicName)
114115
Expect(err).To(BeNil())
115116
}
116117

@@ -121,7 +122,7 @@ func (tp *ToxiProxyContext) AddLatencyToxic(latencyMs int, jitterMs int, toxicit
121122
}
122123
toxicName := fmt.Sprintf("latency_%v", stream)
123124

124-
_, err := tp.Proxy.AddToxic(toxicName, "latency", stream, toxicity, toxiproxyapi.Attributes{
125+
_, err := tp.ToxiProxy.AddToxic(toxicName, "latency", stream, toxicity, toxiproxyapi.Attributes{
125126
"latency": latencyMs,
126127
"jitter": jitterMs,
127128
})

0 commit comments

Comments
 (0)