def check(self): # XXX Ew. If self.results[0].json is empty, the harness won't convert it to a response. errors = self.results[0].json or {} # We should _not_ be seeing Ingress errors here. assert_default_errors(errors, include_ingress_errors=False) for result in self.results: if "mark" in result.query.url: assert not result.headers.get('X-Shadowed', False) elif "check" in result.query.url: data = result.json weighted_total = 0 for i in range(10): # Buckets 0-9 should have 10 per bucket. We'll actually check these values # pretty carefully, because this bit of routing isn't probabilistic. value = data.get(str(i), -1) error = abs(value - 10) assert error <= 2, f'bucket {i} should have 10 calls, got {value}' # Buckets 100-109 should also have 10 per bucket... but honestly, this is # a pretty small sample size, and Envoy's randomization seems to kinda suck # at small sample sizes. Since we're here to test Ambassador's ability to # configure Envoy, rather than trying to test Envoy's ability to properly # weight things, we'll just make sure that _some_ calls got into the shadow # buckets, and not worry about how many it was exactly. wi = i + 100 value = data.get(str(wi), 0) # error = abs(value - 10) # assert error <= 2, f'bucket {wi} should have 10 calls, got {value}' weighted_total += value # See above for why we're just doing a >0 check here. # assert abs(weighted_total - 50) <= 10, f'weighted buckets should have 50 total calls, got {weighted_total}' assert weighted_total > 0, f'weighted buckets should have 50 total calls but got zero'
def check(self): # XXX Ew. If self.results[0].json is empty, the harness won't convert it to a response. errors = self.results[0].json or {} assert_default_errors(errors) for result in self.results: if "mark" in result.query.url: assert not result.headers.get('X-Shadowed', False) elif "check" in result.query.url: data = result.json weighted_total = 0 for i in range(10): # Buckets 0-9 should have 10 per bucket. value = data.get(str(i), -1) error = abs(value - 10) assert error <= 2, f'bucket {i} should have 10 calls, got {value}' # Buckets 100-109 should also have 10 per bucket... but honestly, the randomization # in Envoy seems to kinda suck, so let's just check the total. wi = i + 100 value = data.get(str(wi), -1) # error = abs(value - 10) # assert error <= 2, f'bucket {wi} should have 10 calls, got {value}' weighted_total += value # 20% margin of error is kind of absurd, but # # - small sample sizes kind of suck, and # - we actually don't need to test Envoy's ability to generate random numbers, so meh. assert abs(weighted_total - 50) <= 10, f'weighted buckets should have 50 total calls, got {weighted_total}'
def check(self): # XXX Ew. If self.results[0].json is empty, the harness won't convert it to a response. errors = self.results[0].json # We should _not_ be seeing Ingress errors here. assert_default_errors(errors, include_ingress_errors=False)
def check(self): # XXX Ew. If self.results[0].json is empty, the harness won't convert it to a response. errors = self.results[0].json assert_default_errors(errors)