@@ -41,7 +41,7 @@ func ToxiProxyServerKill(ctx context.Context) error {
41
41
type ToxiProxyContext struct {
42
42
KubeconfigPath string
43
43
ClusterProxy framework.ClusterProxy
44
- Proxy * toxiproxyapi.Proxy
44
+ ToxiProxy * toxiproxyapi.Proxy
45
45
}
46
46
47
47
func SetupForToxiproxyTesting (bootstrapClusterProxy framework.ClusterProxy ) * ToxiProxyContext {
@@ -59,6 +59,7 @@ func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *Tox
59
59
serverRegex := regexp .MustCompilePOSIX ("(https?)://([0-9]+\\ .[0-9]+\\ .[0-9]+\\ .[0-9]+):([0-9]*)" )
60
60
urlComponents := serverRegex .FindStringSubmatch (server )
61
61
Expect (len (urlComponents )).To (Equal (4 ))
62
+ protocol := urlComponents [1 ]
62
63
address := urlComponents [2 ]
63
64
port , err := strconv .Atoi (urlComponents [3 ])
64
65
Expect (err ).To (BeNil ())
@@ -74,7 +75,7 @@ func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *Tox
74
75
Expect (err ).To (BeNil ())
75
76
76
77
// 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 )
78
79
79
80
// Modify the kubeconfig to use the toxiproxy's server url
80
81
err = kubeConfig .SetCurrentServer (toxiProxyServerUrl )
@@ -94,13 +95,13 @@ func SetupForToxiproxyTesting(bootstrapClusterProxy framework.ClusterProxy) *Tox
94
95
return & ToxiProxyContext {
95
96
KubeconfigPath : toxiProxyKubeconfigPath ,
96
97
ClusterProxy : toxiproxyBootstrapClusterProxy ,
97
- Proxy : proxy ,
98
+ ToxiProxy : proxy ,
98
99
}
99
100
}
100
101
101
102
func TearDownToxiProxy (toxiProxyContext * ToxiProxyContext ) {
102
103
// Tear down the proxy
103
- err := toxiProxyContext .Proxy .Delete ()
104
+ err := toxiProxyContext .ToxiProxy .Delete ()
104
105
Expect (err ).To (BeNil ())
105
106
106
107
// Delete the kubeconfig pointing to the proxy
@@ -110,7 +111,7 @@ func TearDownToxiProxy(toxiProxyContext *ToxiProxyContext) {
110
111
}
111
112
112
113
func (tp * ToxiProxyContext ) RemoveToxic (toxicName string ) {
113
- err := tp .Proxy .RemoveToxic (toxicName )
114
+ err := tp .ToxiProxy .RemoveToxic (toxicName )
114
115
Expect (err ).To (BeNil ())
115
116
}
116
117
@@ -121,7 +122,7 @@ func (tp *ToxiProxyContext) AddLatencyToxic(latencyMs int, jitterMs int, toxicit
121
122
}
122
123
toxicName := fmt .Sprintf ("latency_%v" , stream )
123
124
124
- _ , err := tp .Proxy .AddToxic (toxicName , "latency" , stream , toxicity , toxiproxyapi.Attributes {
125
+ _ , err := tp .ToxiProxy .AddToxic (toxicName , "latency" , stream , toxicity , toxiproxyapi.Attributes {
125
126
"latency" : latencyMs ,
126
127
"jitter" : jitterMs ,
127
128
})
0 commit comments