Skip to content

Commit b1edc52

Browse files
skitttpantelis
authored andcommitted
Drop the dependency on wireguard in e2e
The wireguard package has dependencies which can't be built on Windows. If the e2e tests end up with a dependency on the wireguard cable driver, that leaks into subctl and prevents it from being built on Windows. Signed-off-by: Stephen Kitt <[email protected]>
1 parent d9116c4 commit b1edc52

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

pkg/cable/wireguard/driver.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const (
5353
// handshakeTimeout is maximal time from handshake a connections is still considered connected.
5454
handshakeTimeout = 2*time.Minute + 10*time.Second
5555

56-
CableDriverName = "wireguard"
56+
cableDriverName = "wireguard"
5757
receiveBytes = "ReceiveBytes" // for peer connection status
5858
transmitBytes = "TransmitBytes" // for peer connection status
5959
lastChecked = "LastChecked" // for connection peer status
@@ -65,7 +65,7 @@ const (
6565
var logger = log.Logger{Logger: logf.Log.WithName("wireguard")}
6666

6767
func init() {
68-
cable.AddDriver(CableDriverName, NewDriver)
68+
cable.AddDriver(cableDriverName, NewDriver)
6969
}
7070

7171
type specification struct {
@@ -203,7 +203,7 @@ func (w *wireguard) Init() error {
203203
}
204204

205205
func (w *wireguard) GetName() string {
206-
return CableDriverName
206+
return cableDriverName
207207
}
208208

209209
func (w *wireguard) ConnectToEndpoint(endpointInfo *natdiscovery.NATEndpointInfo) (string, error) {
@@ -301,7 +301,7 @@ func (w *wireguard) ConnectToEndpoint(endpointInfo *natdiscovery.NATEndpointInfo
301301

302302
logger.V(log.DEBUG).Infof("Done connecting endpoint peer %s@%s", *remoteKey, remoteIP)
303303

304-
cable.RecordConnection(CableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(v1.Connected), true)
304+
cable.RecordConnection(cableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(v1.Connected), true)
305305

306306
return ip, nil
307307
}
@@ -350,7 +350,7 @@ func (w *wireguard) DisconnectFromEndpoint(remoteEndpoint *types.SubmarinerEndpo
350350
delete(w.connections, remoteEndpoint.Spec.ClusterID)
351351

352352
logger.V(log.DEBUG).Infof("Done removing endpoint for cluster %s", remoteEndpoint.Spec.ClusterID)
353-
cable.RecordDisconnected(CableDriverName, &w.localEndpoint.Spec, &remoteEndpoint.Spec)
353+
cable.RecordDisconnected(cableDriverName, &w.localEndpoint.Spec, &remoteEndpoint.Spec)
354354

355355
return nil
356356
}

pkg/cable/wireguard/getconnections.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ func (w *wireguard) updateConnectionForPeer(p *wgtypes.Peer, connection *v1.Conn
9595
if lc > handshakeTimeout.Milliseconds() {
9696
// No initial handshake for too long.
9797
connection.SetStatus(v1.ConnectionError, "no initial handshake for %.1f seconds", lcSec)
98-
cable.RecordConnection(CableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
98+
cable.RecordConnection(cableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
9999

100100
return
101101
}
102102

103103
if tx > 0 || rx > 0 {
104104
// No handshake, but at least some communication in progress.
105105
connection.SetStatus(v1.Connecting, "no initial handshake yet")
106-
cable.RecordConnection(CableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
106+
cable.RecordConnection(cableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
107107

108108
return
109109
}
@@ -112,7 +112,7 @@ func (w *wireguard) updateConnectionForPeer(p *wgtypes.Peer, connection *v1.Conn
112112
if tx > 0 || rx > 0 {
113113
// All is good.
114114
connection.SetStatus(v1.Connected, "Rx=%d Bytes, Tx=%d Bytes", p.ReceiveBytes, p.TransmitBytes)
115-
cable.RecordConnection(CableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
115+
cable.RecordConnection(cableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
116116
saveAndRecordPeerTraffic(&w.localEndpoint.Spec, &connection.Endpoint, now, p.TransmitBytes, p.ReceiveBytes)
117117

118118
return
@@ -124,7 +124,7 @@ func (w *wireguard) updateConnectionForPeer(p *wgtypes.Peer, connection *v1.Conn
124124
// Hard error, really long time since handshake.
125125
connection.SetStatus(v1.ConnectionError, "no handshake for %.1f seconds",
126126
handshakeDelta.Seconds())
127-
cable.RecordConnection(CableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
127+
cable.RecordConnection(cableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
128128

129129
return
130130
}
@@ -138,14 +138,14 @@ func (w *wireguard) updateConnectionForPeer(p *wgtypes.Peer, connection *v1.Conn
138138
// Soft error, no traffic, stale handshake.
139139
connection.SetStatus(v1.ConnectionError, "no bytes sent or received for %.1f seconds",
140140
lcSec)
141-
cable.RecordConnection(CableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
141+
cable.RecordConnection(cableDriverName, &w.localEndpoint.Spec, &connection.Endpoint, string(connection.Status), false)
142142
}
143143

144144
func (w *wireguard) updatePeerStatus(c *v1.Connection, key *wgtypes.Key) {
145145
p, err := w.peerByKey(key)
146146
if err != nil {
147147
c.SetStatus(v1.ConnectionError, "cannot fetch status for peer %s: %v", key, err)
148-
cable.RecordConnection(CableDriverName, &w.localEndpoint.Spec, &c.Endpoint, string(c.Status), false)
148+
cable.RecordConnection(cableDriverName, &w.localEndpoint.Spec, &c.Endpoint, string(c.Status), false)
149149

150150
return
151151
}
@@ -174,6 +174,6 @@ func saveAndRecordPeerTraffic(localEndpoint, remoteEndpoint *v1.EndpointSpec, lc
174174
remoteEndpoint.BackendConfig[transmitBytes] = strconv.FormatInt(tx, 10)
175175
remoteEndpoint.BackendConfig[receiveBytes] = strconv.FormatInt(rx, 10)
176176

177-
cable.RecordTxBytes(CableDriverName, localEndpoint, remoteEndpoint, int(tx))
178-
cable.RecordRxBytes(CableDriverName, localEndpoint, remoteEndpoint, int(rx))
177+
cable.RecordTxBytes(cableDriverName, localEndpoint, remoteEndpoint, int(tx))
178+
cable.RecordRxBytes(cableDriverName, localEndpoint, remoteEndpoint, int(rx))
179179
}

test/e2e/redundancy/gateway_failover.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/submariner-io/shipyard/test/e2e/framework"
2929
"github.com/submariner-io/shipyard/test/e2e/tcp"
3030
subv1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
31-
"github.com/submariner-io/submariner/pkg/cable/wireguard"
3231
subFramework "github.com/submariner-io/submariner/test/e2e/framework"
3332
v1 "k8s.io/api/core/v1"
3433
"k8s.io/apimachinery/pkg/types"
@@ -82,7 +81,8 @@ func testGatewayPodRestartScenario(f *subFramework.Framework) {
8281

8382
submEndpoint := f.AwaitSubmarinerEndpoint(primaryCluster, subFramework.NoopCheckEndpoint)
8483

85-
if submEndpoint.Spec.Backend == wireguard.CableDriverName &&
84+
// The cable driver name can't be imported from pkg/cable/wireguard to avoid breaking the subctl build on Windows
85+
if submEndpoint.Spec.Backend == "wireguard" &&
8686
framework.DetectProvider(context.TODO(), primaryCluster, gatewayNodes[0].Name) == "kind" {
8787
framework.Skipf("The test is known to fail on Kind 0.21+ with the wireguard cable driver - skipping the test...")
8888
return

0 commit comments

Comments
 (0)