Skip to content

Commit 95734a1

Browse files
author
Nikita Agarwal
committed
Resolve automation file conflicts. Merge branch 'oc-intf-common-code-Jan30' into Nikita_subintf_oc_yang
2 parents 07c6f21 + b4328f2 commit 95734a1

1 file changed

Lines changed: 176 additions & 0 deletions

File tree

translib/transformer/interfaces_openconfig_test.go

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,181 @@ import (
2727
"time"
2828
)
2929

30+
func Test_openconfig_interfaces(t *testing.T) {
31+
var url, url_input_body_json string
32+
33+
t.Log("\n\n+++++++++++++ CONFIGURING INTERFACES ATTRIBUTES ++++++++++++")
34+
t.Log("\n\n--- PATCH interfaces config---")
35+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config"
36+
url_input_body_json = "{\"openconfig-interfaces:config\": { \"mtu\": 8900, \"description\": \"UT_Interface\", \"enabled\": false}}"
37+
t.Run("Test PATCH on interface config", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
38+
time.Sleep(1 * time.Second)
39+
40+
t.Log("\n\n--- Verify PATCH interfaces config ---")
41+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config"
42+
expected_get_json := "{\"openconfig-interfaces:config\": {\"description\": \"UT_Interface\", \"enabled\": false, \"mtu\": 8900, \"name\": \"Ethernet0\"}}"
43+
t.Run("Test GET on interface config", processGetRequest(url, nil, expected_get_json, false))
44+
time.Sleep(1 * time.Second)
45+
46+
t.Log("\n\n--- PATCH interface leaf nodes---")
47+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/enabled"
48+
url_input_body_json = "{\"openconfig-interfaces:enabled\": true}"
49+
t.Run("Test PATCH on interface enabled", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
50+
time.Sleep(1 * time.Second)
51+
52+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/mtu"
53+
url_input_body_json = "{\"openconfig-interfaces:mtu\": 9000}"
54+
t.Run("Test PATCH on interface mtu", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
55+
time.Sleep(1 * time.Second)
56+
57+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/description"
58+
url_input_body_json = "{\"openconfig-interfaces:description\": \"\"}"
59+
t.Run("Test PATCH on interface description", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
60+
time.Sleep(1 * time.Second)
61+
62+
t.Log("\n\n--- Verify PATCH interface leaf nodes ---")
63+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/state"
64+
expected_get_json = "{\"openconfig-interfaces:state\": { \"admin-status\": \"UP\", \"description\": \"\", \"enabled\": true, \"mtu\": 9000, \"name\": \"Ethernet0\"}}"
65+
t.Run("Test GET on interface state", processGetRequest(url, nil, expected_get_json, false))
66+
time.Sleep(1 * time.Second)
67+
68+
t.Log("\n\n--- DELETE at interface enabled ---")
69+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/enabled"
70+
t.Run("Test DELETE on interface enabled", processDeleteRequest(url, true))
71+
time.Sleep(1 * time.Second)
72+
73+
t.Log("\n\n--- Verify DELETE at interface enabled ---")
74+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/enabled"
75+
expected_get_json = "{\"openconfig-interfaces:enabled\": false}"
76+
t.Run("Test GET on interface config", processGetRequest(url, nil, expected_get_json, false))
77+
time.Sleep(1 * time.Second)
78+
79+
t.Log("\n\n--- DELETE at interface mtu ---")
80+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/mtu"
81+
t.Run("Test DELETE on interface mtu", processDeleteRequest(url, true))
82+
time.Sleep(1 * time.Second)
83+
84+
t.Log("\n\n--- Verify DELETE at interface mtu ---")
85+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/mtu"
86+
expected_get_json = "{\"openconfig-interfaces:mtu\": 9100}"
87+
t.Run("Test GET on interface config", processGetRequest(url, nil, expected_get_json, false))
88+
time.Sleep(1 * time.Second)
89+
90+
t.Log("\n\n--- DELETE at interfaces container ---")
91+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]"
92+
err_str := "Physical Interface: Ethernet0 cannot be deleted"
93+
expected_err := tlerr.InvalidArgsError{Format: err_str}
94+
t.Run("Test DELETE on interface container", processDeleteRequest(url, true, expected_err))
95+
time.Sleep(1 * time.Second)
96+
97+
t.Log("\n\n--- DELETE at interface description ---")
98+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/description"
99+
t.Run("Test DELETE on interface description", processDeleteRequest(url, true))
100+
time.Sleep(1 * time.Second)
101+
102+
t.Log("\n\n--- Verify DELETE at interface description ---")
103+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/config/description"
104+
err_str = "Resource not found"
105+
expected_err_invalid := tlerr.NotFoundError{Format: err_str}
106+
t.Run("Test GET on deleted description", processGetRequest(url, nil, "", true, expected_err_invalid))
107+
time.Sleep(1 * time.Second)
108+
109+
t.Log("\n\n--- PATCH interface ---")
110+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]"
111+
url_input_body_json = "{\"openconfig-interfaces:interface\":[{\"name\":\"Ethernet0\",\"config\":{\"name\":\"Ethernet0\",\"mtu\":9100,\"enabled\":true}}]}"
112+
t.Run("Test PATCH on interface", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
113+
time.Sleep(1 * time.Second)
114+
115+
t.Log("\n\n--- Verify PATCH interface ---")
116+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/state"
117+
expected_get_json = "{\"openconfig-interfaces:state\": { \"admin-status\": \"UP\", \"description\": \"\", \"enabled\": true, \"mtu\": 9100, \"name\": \"Ethernet0\"}}"
118+
t.Run("Test GET on interface state", processGetRequest(url, nil, expected_get_json, false))
119+
time.Sleep(1 * time.Second)
120+
}
121+
122+
func Test_openconfig_ethernet(t *testing.T) {
123+
var url, url_input_body_json string
124+
125+
t.Log("\n\n+++++++++++++ CONFIGURING ETHERNET ATTRIBUTES ++++++++++++")
126+
t.Log("\n\n--- PATCH ethernet auto-neg and port-speed ---")
127+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/port-speed"
128+
url_input_body_json = "{\"openconfig-if-ethernet:port-speed\":\"SPEED_40GB\"}"
129+
t.Run("Test PATCH on ethernet port-speed", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
130+
time.Sleep(1 * time.Second)
131+
132+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/auto-negotiate"
133+
url_input_body_json = "{\"openconfig-if-ethernet:auto-negotiate\":true}"
134+
t.Run("Test PATCH on ethernet auto-neg", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
135+
time.Sleep(1 * time.Second)
136+
137+
t.Log("\n\n--- Verify PATCH ethernet ---")
138+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet"
139+
expected_get_json := "{\"openconfig-if-ethernet:ethernet\": {\"config\": {\"auto-negotiate\": true,\"port-speed\": \"openconfig-if-ethernet:SPEED_40GB\"},\"state\": {\"auto-negotiate\": true,\"port-speed\": \"openconfig-if-ethernet:SPEED_40GB\"}}}"
140+
t.Run("Test GET on ethernet", processGetRequest(url, nil, expected_get_json, false))
141+
time.Sleep(1 * time.Second)
142+
143+
t.Log("\n\n--- DELETE at ethernet port-speed---")
144+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/port-speed"
145+
err_str := "DELETE request not allowed for port-speed"
146+
expected_err := tlerr.NotSupportedError{Format: err_str}
147+
t.Run("Test DELETE on ethernet port-speed", processDeleteRequest(url, true, expected_err))
148+
time.Sleep(1 * time.Second)
149+
150+
t.Log("\n\n--- DELETE at ethernet container ---")
151+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet"
152+
t.Run("Test DELETE on ethernet", processDeleteRequest(url, true))
153+
time.Sleep(1 * time.Second)
154+
155+
t.Log("\n\n--- Verify DELETE at ethernet container ---")
156+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/state"
157+
expected_get_json = "{\"openconfig-if-ethernet:state\": {\"auto-negotiate\": true,\"port-speed\": \"openconfig-if-ethernet:SPEED_40GB\"}}"
158+
t.Run("Test GET on ethernet state", processGetRequest(url, nil, expected_get_json, false))
159+
time.Sleep(1 * time.Second)
160+
161+
t.Log("\n\n--- DELETE at ethernet auto-negotiate ---")
162+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/auto-negotiate"
163+
t.Run("Test DELETE on ethernet auto-negotiate", processDeleteRequest(url, true))
164+
time.Sleep(1 * time.Second)
165+
166+
t.Log("\n\n--- Verify DELETE at ethernet auto-negotiate ---")
167+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/auto-negotiate"
168+
err_str = "auto-negotiate not set"
169+
expected_err_invalid := tlerr.InvalidArgsError{Format: err_str}
170+
t.Run("Test GET on deleted auto-negotiate", processGetRequest(url, nil, "", true, expected_err_invalid))
171+
time.Sleep(1 * time.Second)
172+
173+
t.Log("\n\n--- Verify PATCH port-speed to set auto-neg ---")
174+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/port-speed"
175+
url_input_body_json = "{\"openconfig-if-ethernet:port-speed\":\"SPEED_10GB\"}"
176+
time.Sleep(1 * time.Second)
177+
t.Run("Test PATCH on ethernet port-speed", processSetRequest(url, url_input_body_json, "PATCH", false, nil))
178+
time.Sleep(1 * time.Second)
179+
180+
t.Log("\n\n--- Verify PATCH on port-speed to set auto-neg ---")
181+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config"
182+
expected_get_json = "{\"openconfig-if-ethernet:config\": {\"auto-negotiate\": false,\"port-speed\": \"openconfig-if-ethernet:SPEED_10GB\"}}"
183+
t.Run("Test GET on ethernet config", processGetRequest(url, nil, expected_get_json, false))
184+
time.Sleep(1 * time.Second)
185+
186+
t.Log("\n\n--- DELETE at ethernet config ---")
187+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config"
188+
t.Run("Test DELETE on ethernet config", processDeleteRequest(url, true))
189+
time.Sleep(1 * time.Second)
190+
191+
t.Log("\n\n--- Verify DELETE at ethernet config ---")
192+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/auto-negotiate"
193+
expected_get_json = "{\"openconfig-if-ethernet:auto-negotiate\": false}"
194+
t.Run("Test GET on auto-negotiate", processGetRequest(url, nil, expected_get_json, false))
195+
time.Sleep(1 * time.Second)
196+
197+
t.Log("\n\n--- Verify DELETE at ethernet config ---")
198+
url = "/openconfig-interfaces:interfaces/interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/port-speed"
199+
expected_get_json = "{\"openconfig-if-ethernet:port-speed\": \"openconfig-if-ethernet:SPEED_10GB\"}"
200+
t.Run("Test GET on port-speed", processGetRequest(url, nil, expected_get_json, false))
201+
time.Sleep(1 * time.Second)
202+
203+
}
204+
30205
func Test_openconfig_subintf_ipv4(t *testing.T) {
31206
var url, url_input_body_json string
32207

@@ -201,6 +376,7 @@ func Test_openconfig_subintf_ipv4(t *testing.T) {
201376

202377
t.Log("\n\n+++++++++++++ DONE CONFIGURING AND REMOVING IPV4 ADDRESSES ON SUBINTERFACES ++++++++++++")
203378
}
379+
204380
func Test_openconfig_subintf_ipv6(t *testing.T) {
205381
var url, url_input_body_json string
206382

0 commit comments

Comments
 (0)