Skip to content

Commit 07c6f21

Browse files
author
Nikita Agarwal
committed
Updating automation files. Removed family attribute.
1 parent 0ba1402 commit 07c6f21

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

translib/transformer/interfaces_openconfig_test.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"time"
2828
)
2929

30-
func Test_openconfig_subintf(t *testing.T) {
30+
func Test_openconfig_subintf_ipv4(t *testing.T) {
3131
var url, url_input_body_json string
3232

3333
t.Log("\n\n+++++++++++++ CONFIGURING AND REMOVING IPv4 ADDRESS AT SUBINTERFACES ++++++++++++")
@@ -51,7 +51,7 @@ func Test_openconfig_subintf(t *testing.T) {
5151

5252
t.Log("\n\n--- Verify IPv4 address at subinterfaces level ---")
5353
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces"
54-
expected_get_json = "{\"openconfig-interfaces:subinterfaces\": {\"subinterface\": [{\"config\": {\"index\": 0}, \"index\": 0, \"openconfig-if-ip:ipv4\": {\"addresses\": {\"address\": [{\"config\": {\"ip\": \"4.4.4.4\", \"prefix-length\": 24}, \"ip\": \"4.4.4.4\", \"state\":{ \"family\":\"ipv4\", \"ip\": \"4.4.4.4\", \"prefix-length\": 24}}]}}, \"openconfig-if-ip:ipv6\": {\"config\": {\"enabled\": false}}, \"state\": {\"index\": 0}}]}}"
54+
expected_get_json = "{\"openconfig-interfaces:subinterfaces\": {\"subinterface\": [{\"config\": {\"index\": 0}, \"index\": 0, \"openconfig-if-ip:ipv4\": {\"addresses\": {\"address\": [{\"config\": {\"ip\": \"4.4.4.4\", \"prefix-length\": 24}, \"ip\": \"4.4.4.4\", \"state\":{\"ip\": \"4.4.4.4\", \"prefix-length\": 24}}]}}, \"openconfig-if-ip:ipv6\": {\"config\": {\"enabled\": false}}, \"state\": {\"index\": 0}}]}}"
5555
t.Run("Test Get/Verify Patch IPv4 address at subinterfaces level", processGetRequest(url, nil, expected_get_json, false))
5656
time.Sleep(1 * time.Second)
5757

@@ -83,7 +83,7 @@ func Test_openconfig_subintf(t *testing.T) {
8383

8484
t.Log("\n\n--- Verify IPv4 address at subinterfaces/subinterface[index=0] level ---")
8585
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces/subinterface[index=0]"
86-
expected_get_json = "{\"openconfig-interfaces:subinterface\": [{\"config\": {\"index\": 0}, \"index\": 0, \"openconfig-if-ip:ipv4\": {\"addresses\": {\"address\": [{\"config\": {\"ip\": \"4.4.4.4\", \"prefix-length\": 24}, \"ip\": \"4.4.4.4\", \"state\":{ \"family\":\"ipv4\", \"ip\": \"4.4.4.4\", \"prefix-length\": 24}}]}}, \"openconfig-if-ip:ipv6\": {\"config\": {\"enabled\": false}}, \"state\": {\"index\": 0}}]}"
86+
expected_get_json = "{\"openconfig-interfaces:subinterface\": [{\"config\": {\"index\": 0}, \"index\": 0, \"openconfig-if-ip:ipv4\": {\"addresses\": {\"address\": [{\"config\": {\"ip\": \"4.4.4.4\", \"prefix-length\": 24}, \"ip\": \"4.4.4.4\", \"state\":{\"ip\": \"4.4.4.4\", \"prefix-length\": 24}}]}}, \"openconfig-if-ip:ipv6\": {\"config\": {\"enabled\": false}}, \"state\": {\"index\": 0}}]}"
8787
t.Run("Test Get/Verify Patch IPv4 address at subinterface[index=0]", processGetRequest(url, nil, expected_get_json, false))
8888
time.Sleep(1 * time.Second)
8989

@@ -121,7 +121,7 @@ func Test_openconfig_subintf(t *testing.T) {
121121

122122
t.Log("\n\n--- Verify PATCH IPv4 address at addresses level ---")
123123
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces/subinterface[index=0]/openconfig-if-ip:ipv4/addresses"
124-
expected_get_json = "{\"openconfig-if-ip:addresses\": {\"address\": [{\"config\": {\"ip\": \"4.4.4.4\", \"prefix-length\": 24}, \"ip\": \"4.4.4.4\", \"state\":{ \"family\":\"ipv4\", \"ip\": \"4.4.4.4\", \"prefix-length\": 24}}]}}"
124+
expected_get_json = "{\"openconfig-if-ip:addresses\": {\"address\": [{\"config\": {\"ip\": \"4.4.4.4\", \"prefix-length\": 24}, \"ip\": \"4.4.4.4\", \"state\":{ \"ip\": \"4.4.4.4\", \"prefix-length\": 24}}]}}"
125125
t.Run("Test Get/Verify Patch IPv4 address at subinterfaces ipv4/addresses", processGetRequest(url, nil, expected_get_json, false))
126126
time.Sleep(1 * time.Second)
127127

@@ -161,7 +161,7 @@ func Test_openconfig_subintf(t *testing.T) {
161161

162162
t.Log("\n\n--- Verify Get at interfaces/interface[name=Ethernet0] ---")
163163
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]"
164-
expected_get_json = "{\"openconfig-interfaces:interface\":[{\"config\":{\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"openconfig-if-ethernet:ethernet\":{\"config\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"},\"state\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"}},\"name\":\"Ethernet0\",\"state\":{\"admin-status\":\"UP\",\"description\":\"\",\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"subinterfaces\":{\"subinterface\":[{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv4\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"4.4.4.4\",\"prefix-length\":24},\"ip\":\"4.4.4.4\",\"state\":{\"family\":\"ipv4\",\"ip\":\"4.4.4.4\",\"prefix-length\":24}}]}},\"openconfig-if-ip:ipv6\":{\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}}]}"
164+
expected_get_json = "{\"openconfig-interfaces:interface\":[{\"config\":{\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"openconfig-if-ethernet:ethernet\":{\"config\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"},\"state\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"}},\"name\":\"Ethernet0\",\"state\":{\"admin-status\":\"UP\",\"description\":\"\",\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"subinterfaces\":{\"subinterface\":[{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv4\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"4.4.4.4\",\"prefix-length\":24},\"ip\":\"4.4.4.4\",\"state\":{\"ip\":\"4.4.4.4\",\"prefix-length\":24}}]}},\"openconfig-if-ip:ipv6\":{\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}}]}"
165165
t.Run("Test Get at interfaces/interface[name=Ethernet0]", processGetRequest(url, nil, expected_get_json, false))
166166
time.Sleep(1 * time.Second)
167167

@@ -200,6 +200,9 @@ func Test_openconfig_subintf(t *testing.T) {
200200
time.Sleep(1 * time.Second)
201201

202202
t.Log("\n\n+++++++++++++ DONE CONFIGURING AND REMOVING IPV4 ADDRESSES ON SUBINTERFACES ++++++++++++")
203+
}
204+
func Test_openconfig_subintf_ipv6(t *testing.T) {
205+
var url, url_input_body_json string
203206

204207
t.Log("\n\n+++++++++++++ CONFIGURING AND REMOVING IPv6 ADDRESS AT SUBINTERFACES ++++++++++++")
205208
t.Log("\n\n--- Delete/Clear IPv6 address ---")
@@ -209,7 +212,7 @@ func Test_openconfig_subintf(t *testing.T) {
209212

210213
t.Log("\n\n--- Get IPv6 address at subinterfaces ---")
211214
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces"
212-
expected_get_json = "{\"openconfig-interfaces:subinterfaces\": {\"subinterface\": [{\"config\": {\"index\": 0}, \"index\": 0, \"openconfig-if-ip:ipv6\": {\"config\": {\"enabled\": false}}, \"state\": {\"index\": 0}}]}}"
215+
expected_get_json := "{\"openconfig-interfaces:subinterfaces\": {\"subinterface\": [{\"config\": {\"index\": 0}, \"index\": 0, \"openconfig-if-ip:ipv6\": {\"config\": {\"enabled\": false}}, \"state\": {\"index\": 0}}]}}"
213216
t.Run("Test Get IPv6 address at subinterfaces", processGetRequest(url, nil, expected_get_json, false))
214217
time.Sleep(1 * time.Second)
215218

@@ -222,7 +225,7 @@ func Test_openconfig_subintf(t *testing.T) {
222225

223226
t.Log("\n\n--- Verify IPv6 address at subinterfaces level ---")
224227
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces"
225-
expected_get_json = "{\"openconfig-interfaces:subinterfaces\":{\"subinterface\":[{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv6\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"family\":\"ipv6\",\"ip\":\"a::e\",\"prefix-length\":64}}]},\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}}"
228+
expected_get_json = "{\"openconfig-interfaces:subinterfaces\":{\"subinterface\":[{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv6\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"ip\":\"a::e\",\"prefix-length\":64}}]},\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}}"
226229
t.Run("Test Get/Verify Patch IPv6 address at subinterfaces level", processGetRequest(url, nil, expected_get_json, false))
227230
time.Sleep(1 * time.Second)
228231

@@ -248,7 +251,7 @@ func Test_openconfig_subintf(t *testing.T) {
248251

249252
t.Log("\n\n--- Verify PATCH IPv6 address at subinterface level ---")
250253
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces/subinterface"
251-
expected_get_json = "{\"openconfig-interfaces:subinterface\": [{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv6\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"family\":\"ipv6\",\"ip\":\"a::e\",\"prefix-length\":64}}]},\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}"
254+
expected_get_json = "{\"openconfig-interfaces:subinterface\": [{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv6\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"ip\":\"a::e\",\"prefix-length\":64}}]},\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}"
252255
t.Run("Test Get/Verify Patch IPv6 address at subinterface", processGetRequest(url, nil, expected_get_json, false))
253256
time.Sleep(1 * time.Second)
254257

@@ -274,7 +277,7 @@ func Test_openconfig_subintf(t *testing.T) {
274277

275278
t.Log("\n\n--- Verify PATCH IPv6 address at addresses level ---")
276279
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces/subinterface[index=0]/openconfig-if-ip:ipv6/addresses"
277-
expected_get_json = "{\"openconfig-if-ip:addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"family\":\"ipv6\",\"ip\":\"a::e\",\"prefix-length\":64}}]}}"
280+
expected_get_json = "{\"openconfig-if-ip:addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"ip\":\"a::e\",\"prefix-length\":64}}]}}"
278281
t.Run("Test Get/Verify Patch IPv6 address at subinterfaces addresses", processGetRequest(url, nil, expected_get_json, false))
279282
time.Sleep(1 * time.Second)
280283

@@ -308,17 +311,16 @@ func Test_openconfig_subintf(t *testing.T) {
308311

309312
t.Log("\n\n--- Verify Get at interfaces/interface[name=Ethernet0] ---")
310313
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]"
311-
expected_get_json = "{\"openconfig-interfaces:interface\":[{\"config\":{\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"openconfig-if-ethernet:ethernet\":{\"config\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"},\"state\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"}},\"name\":\"Ethernet0\",\"state\":{\"admin-status\":\"UP\",\"description\":\"\",\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"subinterfaces\":{\"subinterface\":[{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv6\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"family\":\"ipv6\",\"ip\":\"a::e\",\"prefix-length\":64}}]},\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}}]}"
312-
314+
expected_get_json = "{\"openconfig-interfaces:interface\":[{\"config\":{\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"openconfig-if-ethernet:ethernet\":{\"config\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"},\"state\":{\"auto-negotiate\":false,\"port-speed\":\"openconfig-if-ethernet:SPEED_10GB\"}},\"name\":\"Ethernet0\",\"state\":{\"admin-status\":\"UP\",\"description\":\"\",\"enabled\":true,\"mtu\":9100,\"name\":\"Ethernet0\"},\"subinterfaces\":{\"subinterface\":[{\"config\":{\"index\":0},\"index\":0,\"openconfig-if-ip:ipv6\":{\"addresses\":{\"address\":[{\"config\":{\"ip\":\"a::e\",\"prefix-length\":64},\"ip\":\"a::e\",\"state\":{\"ip\":\"a::e\",\"prefix-length\":64}}]},\"config\":{\"enabled\":false}},\"state\":{\"index\":0}}]}}]}"
313315
t.Run("Test Get at interfaces/interface[name=Ethernet0]", processGetRequest(url, nil, expected_get_json, false))
314316
time.Sleep(1 * time.Second)
315317

316318
//------------------------------------------------------------------------------------------------------------------------------------
317319

318320
t.Log("\n\n--- Negative test: Delete IPv6 config container ---")
319321
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/subinterfaces/subinterface[index=0]/openconfig-if-ip:ipv6/config"
320-
err_str = "Delete not allowed at this container"
321-
expected_err_2 = tlerr.NotSupportedError{Format: err_str}
322+
err_str := "Delete not allowed at this container"
323+
expected_err_2 := tlerr.NotSupportedError{Format: err_str}
322324
time.Sleep(1 * time.Second)
323325
t.Run("Test Delete IPv6 config", processDeleteRequest(url, true, expected_err_2))
324326
time.Sleep(1 * time.Second)

0 commit comments

Comments
 (0)