Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We need to wait couple seconds till namespace is not created #80

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions container_ci_suite/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,37 @@ def create_project(self):
run_oc_command(f"project {self.namespace}", json_output=False)
return self.openshift_ops.is_project_exits()

def create_tenant_namespace(self) -> bool:
tenant_yaml_file = utils.save_tenant_namespace_yaml(project_name=self.shared_random_name)
try:
tentant_output = run_oc_command(cmd=f"create -f {tenant_yaml_file}", json_output=False, return_output=True)
print(tentant_output)
except subprocess.CalledProcessError:
print(f"Create tenant namespace with the name '{self.shared_random_name}' was not successful.")
return False
return True

def create_egress_rules(self) -> bool:
tenant_egress_file = utils.save_tenant_egress_yaml(project_name=self.shared_random_name)
try:
tentant_output = run_oc_command(cmd=f"apply -f {tenant_egress_file}", json_output=False, return_output=True)
print(tentant_output)
except subprocess.CalledProcessError:
print(f"Apply egress rules to tenant namespace '{self.shared_random_name}' was not successful.")
self.delete_tenant_namespace()
return False
return True

def prepare_tenant_namespace(self):
print(f"Prepare Tenant Namespace with name: '{self.shared_random_name}'")
json_flag = False
self.login_to_shared_cluster()
tenant_yaml_file = utils.save_tenant_namespace_yaml(project_name=self.shared_random_name)
tentant_output = run_oc_command(cmd=f"create -f {tenant_yaml_file}", json_output=json_flag, return_output=True)
print(tentant_output)
tenant_egress_file = utils.save_tenant_egress_yaml(project_name=self.shared_random_name)
tentant_output = run_oc_command(cmd=f"apply -f {tenant_egress_file}", json_output=False, return_output=True)
print(tentant_output)
if not self.create_tenant_namespace():
return False
# Let's wait 3 seconds till project is not up
time.sleep(3)
if not self.create_egress_rules():
return False
run_oc_command(
cmd=f"project {self.namespace}",
json_output=json_flag,
Expand Down
Loading