@@ -17,127 +17,20 @@ package integration
17
17
18
18
import (
19
19
"fmt"
20
- "os"
21
20
"os/exec"
22
21
"runtime/debug"
23
22
"strings"
24
- "time"
25
23
26
- "github.com/contiv/contivmodel"
27
- "github.com/contiv/netplugin/core"
28
- "github.com/contiv/netplugin/netmaster/daemon"
29
24
"github.com/contiv/netplugin/netmaster/intent"
30
25
"github.com/contiv/netplugin/netmaster/master"
31
26
"github.com/contiv/netplugin/netmaster/mastercfg"
32
- "github.com/contiv/netplugin/netplugin/agent"
33
27
"github.com/contiv/netplugin/netplugin/cluster"
34
- "github.com/contiv/netplugin/netplugin/plugin"
35
28
"github.com/contiv/ofnet"
36
29
37
30
log "github.com/Sirupsen/logrus"
38
31
. "gopkg.in/check.v1"
39
32
)
40
33
41
- type clusterState struct {
42
- masterDaemon * daemon.MasterDaemon // master instance
43
- pluginAgent * agent.Agent // netplugin agent
44
- hostLabel string // local host name
45
- localIP string // local ip addr
46
- uniqEPID uint64 // rolling int to generate unique EP IDs
47
- }
48
-
49
- // newCluster creates a new cluster of netplugin/netmaster
50
- func newCluster (fwdMode , clusterStore string ) (* clusterState , error ) {
51
- // get local host name
52
- hostLabel , err := os .Hostname ()
53
- if err != nil {
54
- log .Fatalf ("Failed to fetch hostname. Error: %s" , err )
55
- }
56
-
57
- // get local IP addr
58
- localIP , err := cluster .GetLocalAddr ()
59
- if err != nil {
60
- log .Fatalf ("Error getting local address. Err: %v" , err )
61
- }
62
-
63
- // create master daemon
64
- md := & daemon.MasterDaemon {
65
- ListenURL : ":9999" ,
66
- ClusterStore : clusterStore ,
67
- ClusterMode : "test" ,
68
- DNSEnabled : false ,
69
- }
70
-
71
- // initialize the plugin config
72
- pluginConfig := plugin.Config {
73
- Drivers : plugin.Drivers {
74
- Network : "ovs" ,
75
- State : strings .Split (clusterStore , "://" )[0 ],
76
- },
77
- Instance : core.InstanceInfo {
78
- HostLabel : hostLabel ,
79
- CtrlIP : localIP ,
80
- VtepIP : localIP ,
81
- VlanIntf : "eth2" ,
82
- DbURL : clusterStore ,
83
- PluginMode : "test" ,
84
- },
85
- }
86
-
87
- // initialize master daemon
88
- md .Init ()
89
-
90
- // Run daemon FSM
91
- go md .RunMasterFsm ()
92
-
93
- // Wait for a second for master to initialize
94
- time .Sleep (time .Second )
95
-
96
- // set forwarding mode if required
97
- if fwdMode != "bridge" {
98
- err := contivModel .CreateGlobal (& contivModel.Global {
99
- Key : "global" ,
100
- Name : "global" ,
101
- NetworkInfraType : "default" ,
102
- Vlans : "1-4094" ,
103
- Vxlans : "1-10000" ,
104
- FwdMode : fwdMode ,
105
- })
106
- if err != nil {
107
- log .Fatalf ("Error creating global state. Err: %v" , err )
108
- }
109
- }
110
-
111
- // Create a new agent
112
- ag := agent .NewAgent (& pluginConfig )
113
-
114
- // Process all current state
115
- ag .ProcessCurrentState ()
116
-
117
- // post initialization processing
118
- ag .PostInit ()
119
-
120
- // handle events
121
- go func () {
122
- if err := ag .HandleEvents (); err != nil {
123
- log .Infof ("Netplugin exiting due to error: %v" , err )
124
- os .Exit (1 )
125
- }
126
- }()
127
-
128
- // Wait for a second for things to settle down
129
- time .Sleep (time .Second )
130
-
131
- cl := & clusterState {
132
- masterDaemon : md ,
133
- pluginAgent : ag ,
134
- hostLabel : hostLabel ,
135
- localIP : localIP ,
136
- }
137
-
138
- return cl , nil
139
- }
140
-
141
34
// assertNoErr utility function to assert no error
142
35
func assertNoErr (err error , c * C , msg string ) {
143
36
if err != nil {
@@ -169,8 +62,8 @@ func (its *integTestSuite) allocAddress(addrPool, networkID, prefAddress string)
169
62
170
63
// createEndpoint creates an endpoint using netplugin api
171
64
func (its * integTestSuite ) createEndpoint (tenantName , netName , epgName , v4Addr , v6Addr string ) (* mastercfg.CfgEndpointState , error ) {
172
- its .cluster . uniqEPID ++
173
- epID := fmt .Sprintf ("%s-%s-%s-%d" , tenantName , netName , epgName , its .cluster . uniqEPID )
65
+ its .uniqEPID ++
66
+ epID := fmt .Sprintf ("%s-%s-%s-%d" , tenantName , netName , epgName , its .uniqEPID )
174
67
// Build endpoint request
175
68
mreq := master.CreateEndpointRequest {
176
69
TenantName : tenantName ,
@@ -179,7 +72,7 @@ func (its *integTestSuite) createEndpoint(tenantName, netName, epgName, v4Addr,
179
72
EndpointID : epID ,
180
73
ConfigEP : intent.ConfigEP {
181
74
Container : epID ,
182
- Host : its .cluster . hostLabel ,
75
+ Host : its .npcluster . HostLabel ,
183
76
IPAddress : v4Addr ,
184
77
IPv6Address : v6Addr ,
185
78
ServiceName : epgName ,
@@ -197,7 +90,7 @@ func (its *integTestSuite) createEndpoint(tenantName, netName, epgName, v4Addr,
197
90
netID := netName + "." + tenantName
198
91
199
92
// Ask netplugin to create the endpoint
200
- err = its .cluster . pluginAgent .Plugin ().CreateEndpoint (netID + "-" + epID )
93
+ err = its .npcluster . PluginAgent .Plugin ().CreateEndpoint (netID + "-" + epID )
201
94
if err != nil {
202
95
log .Errorf ("Endpoint creation failed. Error: %s" , err )
203
96
return nil , err
@@ -265,7 +158,7 @@ func (its *integTestSuite) deleteEndpoint(tenantName, netName, epgName string, e
265
158
}
266
159
267
160
// delete the endpoint
268
- err = its .cluster . pluginAgent .Plugin ().DeleteEndpoint (epCfg .ID )
161
+ err = its .npcluster . PluginAgent .Plugin ().DeleteEndpoint (epCfg .ID )
269
162
if err != nil {
270
163
log .Errorf ("Error deleting endpoint %s. Err: %v" , epCfg .ID , err )
271
164
return err
@@ -312,7 +205,7 @@ func (its *integTestSuite) verifyEndpointInspect(tenantName, netName string, epC
312
205
c .Assert (ep .IpAddress [0 ], Equals , epCfg .IPAddress )
313
206
c .Assert (ep .Network , Equals , fmt .Sprintf ("%s.%s" , netName , tenantName ))
314
207
c .Assert (ep .MacAddress , Equals , epCfg .MacAddress )
315
- c .Assert (ep .HomingHost , Equals , its .cluster . hostLabel )
208
+ c .Assert (ep .HomingHost , Equals , its .npcluster . HostLabel )
316
209
foundCount ++
317
210
}
318
211
}
0 commit comments