MCPcopy
hub / github.com/google/seesaw / interfaceTests

Function interfaceTests

test_tools/ncc_test_tool/main.go:159–307  ·  view source on GitHub ↗
(ncc client.NCC)

Source from the content-addressed store, hash-verified

157}
158
159func interfaceTests(ncc client.NCC) {
160 iface := *testIface
161 vip := net.ParseIP(*clusterVIPStr)
162 rtID := uint8(*routingTableID)
163
164 out, err := exec.Command(ipCmd, "link", "show", "dev", iface).Output()
165 if err != nil {
166 log.Fatalf("Failed to get link state for %v: %v", iface, err)
167 }
168 if !strings.Contains(string(out), " state DOWN ") {
169 log.Fatalf("Link state for %v is not DOWN: %v", iface, string(out))
170 }
171
172 out, err = exec.Command(ipCmd, "addr", "show", "dev", iface).Output()
173 if err != nil {
174 log.Fatalf("Failed to get addresses for %v: %v", iface, err)
175 }
176 if !strings.Contains(string(out), fmt.Sprintf(" inet %s/", vip)) {
177 log.Fatalf("VIP address is not configured on interface: %v", string(out))
178 }
179
180 out, err = exec.Command(ipCmd, "rule", "show").Output()
181 if err != nil {
182 log.Fatalf("Failed to get routing policy: %v", err)
183 }
184 rpFrom := fmt.Sprintf("from %s lookup %d", vip, rtID)
185 if !strings.Contains(string(out), rpFrom) {
186 log.Fatalf("Routing policy (from) is not correctly configured for %s: %v", vip, string(out))
187 }
188 rpTo := fmt.Sprintf("from all to %s lookup %d", vip, rtID)
189 if !strings.Contains(string(out), rpTo) {
190 log.Fatalf("Routing policy (to) is not correctly configured for %s: %v", vip, string(out))
191 }
192
193 lb := lbInterface(ncc)
194
195 // Add a unicast VIP.
196 unicastVIP := seesaw.NewVIP(net.ParseIP(*unicastVIPStr), nil)
197 if err := lb.AddVIP(unicastVIP); err != nil {
198 log.Fatalf("Failed to add VIP %v: %v", unicastVIP, err)
199 }
200
201 out, err = exec.Command(ipCmd, "addr", "show", "dev", iface).Output()
202 if err != nil {
203 log.Fatalf("Failed to get addresses for %v: %v", iface, err)
204 }
205 if !strings.Contains(string(out), fmt.Sprintf(" inet %s/", unicastVIP)) {
206 log.Fatalf("Unicast VIP address is not configured on interface: %v", string(out))
207 }
208
209 // Going up...
210 if err := lb.Up(); err != nil {
211 log.Fatalf("Failed to bring LB interface up: %v", err)
212 }
213
214 out, err = exec.Command(ipCmd, "link", "show", "dev", iface).Output()
215 if err != nil {
216 log.Fatalf("Failed to get link state for %v: %v", iface, err)

Callers 1

mainFunction · 0.85

Calls 9

NewVIPFunction · 0.92
lbInterfaceFunction · 0.85
CommandMethod · 0.80
AddVIPMethod · 0.65
UpMethod · 0.65
DeleteVIPMethod · 0.65
AddVLANMethod · 0.65
DeleteVLANMethod · 0.65
DownMethod · 0.65

Tested by

no test coverage detected