forked from kata-containers/kata-containers
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ipvlan_endpoint_test.go
51 lines (40 loc) · 1.08 KB
/
ipvlan_endpoint_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//go:build linux
// +build linux
// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package virtcontainers
import (
"net"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCreateIPVlanEndpoint(t *testing.T) {
assert := assert.New(t)
macAddr := net.HardwareAddr{0x02, 0x00, 0xCA, 0xFE, 0x00, 0x04}
expected := &IPVlanEndpoint{
NetPair: NetworkInterfacePair{
TapInterface: TapInterface{
ID: "uniqueTestID-5",
Name: "br5_kata",
TAPIface: NetworkInterface{
Name: "tap5_kata",
},
},
VirtIface: NetworkInterface{
Name: "eth5",
HardAddr: macAddr.String(),
},
NetInterworkingModel: NetXConnectTCFilterModel,
},
EndpointType: IPVlanEndpointType,
}
result, err := createIPVlanNetworkEndpoint(5, "")
assert.NoError(err)
// the resulting ID will be random - so let's overwrite to test the rest of the flow
result.NetPair.ID = "uniqueTestID-5"
// the resulting mac address will be random - so lets overwrite it
result.NetPair.VirtIface.HardAddr = macAddr.String()
assert.Exactly(result, expected)
}