Skip to content

Commit c898447

Browse files
committed
Changes due to review feedback.
1 parent e33bdec commit c898447

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

test/e2e/deploy_app_toxi.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 The Kubernetes Authors.
2+
Copyright 2022 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -40,15 +40,15 @@ func DeployAppToxiSpec(ctx context.Context, inputGetter func() CommonSpecInput)
4040
namespace *corev1.Namespace
4141
cancelWatches context.CancelFunc
4242
clusterResources *clusterctl.ApplyClusterTemplateAndWaitResult
43+
toxicName string
44+
toxiProxyContext *helpers.ToxiProxyContext = nil
4345
appName = "httpd"
4446
appManifestPath = "data/fixture/sample-application.yaml"
4547
expectedHtmlPath = "data/fixture/expected-webpage.html"
4648
appDeploymentReadyTimeout = 180
4749
appPort = 8080
4850
appDefaultHtmlPath = "/"
4951
expectedHtml = ""
50-
toxiProxyContext *helpers.ToxiProxyContext = nil
51-
toxicName string
5252
)
5353

5454
BeforeEach(func() {
@@ -64,8 +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-
toxiProxyContext = helpers.SetupForToxiproxyTesting(input.BootstrapClusterProxy)
68-
toxicName = toxiProxyContext.AddLatencyToxic(100, 10, 100, false)
67+
toxiProxyContext = helpers.SetupForToxiProxyTesting(input.BootstrapClusterProxy)
68+
const TOXIC_LATENCY_MS = 100
69+
const TOXIC_JITTER_MS = 100
70+
const TOXIC_TOXICITY = 1
71+
toxicName = toxiProxyContext.AddLatencyToxic(TOXIC_LATENCY_MS, TOXIC_JITTER_MS, TOXIC_TOXICITY, false)
6972

7073
// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events.
7174
namespace, cancelWatches = setupSpecNamespace(ctx, specName, toxiProxyContext.ClusterProxy, input.ArtifactFolder)

test/e2e/helpers/kubeconfig.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func (k *Kubeconfig) GetCurrentClusterName() (string, error) {
130130
}
131131

132132
return castClusterName, nil
133-
134133
}
135134

136135
func (k *Kubeconfig) GetCurrentCluster() (map[string]interface{}, error) {

test/e2e/helpers/toxiProxy.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type ToxiProxyContext struct {
4444
ToxiProxy *toxiproxyapi.Proxy
4545
}
4646

47-
func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *ToxiProxyContext {
47+
func SetupForToxiProxyTesting(bootstrapClusterProxy framework.ClusterProxy) *ToxiProxyContext {
4848
// Read/parse the actual kubeconfig for the cluster
4949
kubeConfig := NewKubeconfig()
5050
unproxiedKubeconfigPath := bootstrapClusterProxy.GetKubeconfigPath()
@@ -90,7 +90,12 @@ func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *Tox
9090
Expect(err).To(BeNil())
9191

9292
// Create a new ClusterProxy using the new kubeconfig
93-
toxiproxyBootstrapClusterProxy := framework.NewClusterProxy("toxiproxy-bootstrap", toxiProxyKubeconfigPath, bootstrapClusterProxy.GetScheme(), framework.WithMachineLogCollector(framework.DockerLogCollector{}))
93+
toxiproxyBootstrapClusterProxy := framework.NewClusterProxy(
94+
"toxiproxy-bootstrap",
95+
toxiProxyKubeconfigPath,
96+
bootstrapClusterProxy.GetScheme(),
97+
framework.WithMachineLogCollector(framework.DockerLogCollector{}),
98+
)
9499

95100
return &ToxiProxyContext{
96101
KubeconfigPath: toxiProxyKubeconfigPath,
@@ -107,7 +112,6 @@ func TearDownToxiProxy(toxiProxyContext *ToxiProxyContext) {
107112
// Delete the kubeconfig pointing to the proxy
108113
err = os.Remove(toxiProxyContext.KubeconfigPath)
109114
Expect(err).To(BeNil())
110-
111115
}
112116

113117
func (tp *ToxiProxyContext) RemoveToxic(toxicName string) {

0 commit comments

Comments
 (0)