forked from eBay/go-ovn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logical_router_port_test.go
100 lines (87 loc) · 1.74 KB
/
logical_router_port_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package goovn
import (
"github.com/stretchr/testify/assert"
"testing"
)
const LR4 = "lr4"
func TestLogicalRouterPort(t *testing.T) {
ovndbapi := getOVNClient(DBNB)
var cmds []*OvnCommand
var cmd *OvnCommand
var err error
cmds = make([]*OvnCommand, 0)
cmd, err = ovndbapi.LRAdd(LR4, nil)
if err != nil {
t.Fatal(err)
}
cmds = append(cmds, cmd)
err = ovndbapi.Execute(cmds...)
if err != nil {
t.Fatal(err)
}
lrs, err := ovndbapi.LRList()
if err != nil {
t.Fatal(err)
}
if len(lrs) == 0 {
t.Fatalf("lr not created %v", lrs)
}
// lr string, lrp string, mac string, network []string, peer string
cmd, err = ovndbapi.LRPAdd(LR4, LRP, "54:54:54:54:54:54", []string{"192.168.0.1/24"}, "lrp2", nil)
if err != nil {
t.Fatal(err)
}
err = ovndbapi.Execute(cmd)
if err != nil {
t.Fatal(err)
}
lrps, err := ovndbapi.LRPList(LR4)
if err != nil {
t.Fatal(err)
}
if len(lrps) != 1 {
t.Fatalf("lrp not created %v", lrps)
}
cmd, err = ovndbapi.LRPDel(LR4, LRP)
if err != nil {
t.Fatal(err)
}
err = ovndbapi.Execute(cmd)
if err != nil {
t.Fatal(err)
}
lrps, err = ovndbapi.LRPList(LR4)
if err != nil {
t.Fatal(err)
}
if len(lrps) != 0 {
t.Fatalf("lrp not created %v", lrps)
}
cmd, err = ovndbapi.LRDel(LR4)
if err != nil {
t.Fatal(err)
}
err = ovndbapi.Execute(cmd)
if err != nil {
t.Fatal(err)
}
lrs, err = ovndbapi.LRList()
if err != nil {
t.Fatal(err)
}
if len(lrs) > 0 {
for _, lr := range lrs {
if lr.Name == LR4 {
t.Fatalf("lr not deleted %v", LR4)
break
}
}
} else {
t.Logf("Successfully deleted router %s", LR4)
}
// verify router port list for non-existing routers
_, err = ovndbapi.LRPList(FAKENOROUTER)
if err != nil {
assert.EqualError(t, ErrorNotFound, err.Error())
}
}