@@ -197,6 +197,54 @@ func TestClientVSwitchGetControllerOK(t *testing.T) {
197
197
}
198
198
}
199
199
200
+ func TestClienCreateSFlow (t * testing.T ) {
201
+ var (
202
+ id = "830bab0b-4149-4f5e-b213-06c6d8a727b9"
203
+ bridge = "br0"
204
+ collectorIP = "10.0.0.10"
205
+ collectorPort = "6343"
206
+ agentIP = "ovsbr0"
207
+ headerBytes = "128"
208
+ samplingN = "64"
209
+ pollingSecs = "5"
210
+ )
211
+
212
+ // Apply Timeout option to verify arguments
213
+ c := testClient ([]OptionFunc {Timeout (1 )}, func (cmd string , args ... string ) ([]byte , error ) {
214
+ // Verify correct command and arguments passed, including option flags
215
+ if want , got := "ovs-vsctl" , cmd ; want != got {
216
+ t .Fatalf ("incorrect command:\n - want: %v\n - got: %v" ,
217
+ want , got )
218
+ }
219
+
220
+ wantArgs := []string {
221
+ "--timeout=1" ,
222
+ "--" ,
223
+ "--id=@sflow" , "create" , "sflow" , fmt .Sprintf ("agent=%s" , agentIP ), fmt .Sprintf ("target=\" %s:%s\" " , collectorIP , collectorPort ),
224
+ fmt .Sprintf ("header=%s" , headerBytes ), fmt .Sprintf ("sampling=%s" , samplingN ), fmt .Sprintf ("polling=%s" , pollingSecs ),
225
+ "--" ,
226
+ "set" , "bridge" , bridge , "sflow=@sflow" ,
227
+ }
228
+
229
+ if want , got := wantArgs , args ; ! reflect .DeepEqual (want , got ) {
230
+ t .Fatalf ("incorrect arguments\n - want: %v\n - got: %v" ,
231
+ want , got )
232
+ }
233
+
234
+ return []byte (id ), nil
235
+ })
236
+
237
+ sflowID , err := c .VSwitch .CreateSFlow (bridge , agentIP , collectorIP , collectorPort , headerBytes , samplingN , pollingSecs )
238
+ if err != nil {
239
+ t .Fatalf ("unexpected error for Client.VSwitch.CreateSflow: %v" , err )
240
+ }
241
+
242
+ if sflowID != id {
243
+ t .Fatalf ("sFlowID missmatch\n - got: %v\n - want: %v" , sflowID , id )
244
+ }
245
+
246
+ }
247
+
200
248
func TestClientVSwitchListPorts (t * testing.T ) {
201
249
tests := []struct {
202
250
name string
0 commit comments