(ncc client.NCC)
| 157 | } |
| 158 | |
| 159 | func 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) |
no test coverage detected