Amend check_sg_rules_for_np() method

Move ingress_cidrs_found and egress_cidrs_initialization to
inside the while loop so they're cleared in each iteration.
Move rule match comprobation outside the rules for loop.

Change-Id: I1acba9f407de084f19d9ee12fb6e95de03d578df
This commit is contained in:
Jon Uriarte 2022-01-14 18:07:34 +00:00
parent 5fd8c32c31
commit d9a93bcba9

View File

@ -66,8 +66,6 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest,
egress_cidrs_should_exist=(),
ingress_cidrs_shouldnt_exist=(),
egress_cidrs_shouldnt_exist=()):
ingress_cidrs_found = set()
egress_cidrs_found = set()
ingress_cidrs_should_exist = set(ingress_cidrs_should_exist)
egress_cidrs_should_exist = set(egress_cidrs_should_exist)
ingress_cidrs_shouldnt_exist = set(ingress_cidrs_shouldnt_exist)
@ -77,6 +75,8 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest,
start = time.time()
while not rules_match and (time.time() - start) < TIMEOUT_PERIOD:
ingress_cidrs_found = set()
egress_cidrs_found = set()
sg_rules = self.get_sg_rules_for_np(namespace, np)
for rule in sg_rules:
@ -94,8 +94,9 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest,
or not egress_cidrs_shouldnt_exist.issubset(
egress_cidrs_found))):
rules_match = True
else:
time.sleep(10)
time.sleep(1)
if not rules_match:
msg = 'Timed out waiting sg rules for np %s to match' % np
raise lib_exc.TimeoutException(msg)