(t *testing.T)
| 131 | } |
| 132 | |
| 133 | func TestHealthcheckHTTP(t *testing.T) { |
| 134 | t.Parallel() |
| 135 | h := NewHarness(t) |
| 136 | |
| 137 | // IPs |
| 138 | clientIP := GetIP(h.Subnet, 20) |
| 139 | primaryIP := GetIP(h.Subnet, 21) |
| 140 | backupIP := GetIP(h.Subnet, 22) |
| 141 | |
| 142 | // Keys |
| 143 | clientKey := state.GenerateKey() |
| 144 | primaryKey := state.GenerateKey() |
| 145 | backupKey := state.GenerateKey() |
| 146 | |
| 147 | configDir := h.SetupTestDir() |
| 148 | |
| 149 | // Service IP that we are load balancing / checking |
| 150 | serviceIP := "10.0.3.1" |
| 151 | servicePrefixStr := serviceIP + "/32" |
| 152 | servicePrefix := netip.MustParsePrefix(servicePrefixStr) |
| 153 | |
| 154 | // 1. Central Config |
| 155 | central := state.CentralCfg{ |
| 156 | Routers: []state.RouterCfg{ |
| 157 | SimpleRouter("client", clientKey.Pubkey(), "10.0.0.10", clientIP), |
| 158 | SimpleRouter("primary", primaryKey.Pubkey(), "10.0.0.11", primaryIP), |
| 159 | SimpleRouter("backup", backupKey.Pubkey(), "10.0.0.12", backupIP), |
| 160 | }, |
| 161 | Graph: []string{ |
| 162 | "client, primary", |
| 163 | "client, backup", |
| 164 | }, |
| 165 | Timestamp: time.Now().UnixNano(), |
| 166 | } |
| 167 | |
| 168 | // Configure Primary with HTTP check (Metric 10) |
| 169 | central.Routers[1].Prefixes = []state.PrefixHealthWrapper{ |
| 170 | { |
| 171 | &state.HTTPPrefixHealth{ |
| 172 | Prefix: servicePrefix, |
| 173 | URL: fmt.Sprintf("http://%s:8080/health", serviceIP), |
| 174 | Delay: new(1 * time.Second), |
| 175 | Metric: new(uint32(10)), |
| 176 | }, |
| 177 | }, |
| 178 | } |
| 179 | |
| 180 | // Configure Backup with Static check (Metric 1000) |
| 181 | backupMetric := uint32(1000) |
| 182 | central.Routers[2].Prefixes = []state.PrefixHealthWrapper{ |
| 183 | { |
| 184 | &state.StaticPrefixHealth{ |
| 185 | Prefix: servicePrefix, |
| 186 | Metric: backupMetric, |
| 187 | }, |
| 188 | }, |
| 189 | } |
| 190 |
nothing calls this directly
no test coverage detected