Skip to content

Commit

Permalink
Deploy channel in setup step
Browse files Browse the repository at this point in the history
This is a better place, so we can write tests deploying multiple
applications without deploying the channel multiple times.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Nov 16, 2023
1 parent 05a9a17 commit 5783bde
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions test/drenv/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ def setup():
Set the environemnt for running the tests.
"""
_deploy_dr_policy()
_deploy_channel()


def teardown():
"""
Undo changes made in setup().
"""
_delete_channel()
_delete_dr_policy()


Expand All @@ -122,10 +124,10 @@ def _deploy_dr_policy():
- {env['clusters'][1]}
schedulingInterval: 1m
"""
info("Deploying drpolicy {config['dr_policy']}")
info(f"Deploying drpolicy {config['dr_policy']}")
kubectl.apply("--filename=-", input=dr_policy, context=env["hub"], log=debug)

info("Waiting until drpolicy {config['dr_policy']} is validated")
info(f"Waiting until drpolicy {config['dr_policy']} is validated")
kubectl.wait(
"drpolicy",
config["dr_policy"],
Expand All @@ -136,7 +138,7 @@ def _deploy_dr_policy():


def _delete_dr_policy():
info("Deleting drpolicy {config['dr_policy']}")
info(f"Deleting drpolicy {config['dr_policy']}")
kubectl.delete(
"drpolicy",
config["dr_policy"],
Expand All @@ -146,16 +148,29 @@ def _delete_dr_policy():
)


def deploy():
"""
Deploy application on cluster.
"""
def _deploy_channel():
info("Deploying channel")
kubectl.apply(
f"--kustomize={config['repo']}/channel?ref={config['branch']}",
context=env["hub"],
log=debug,
)


def _delete_channel():
info("Undeploying channel")
kubectl.delete(
f"--kustomize={config['repo']}/channel?ref={config['branch']}",
"--ignore-not-found",
context=env["hub"],
log=debug,
)


def deploy():
"""
Deploy application on cluster.
"""
info("Deploying application")
kubectl.apply(
f"--kustomize={config['repo']}/{config['path']}?ref={config['branch']}",
Expand All @@ -168,13 +183,6 @@ def undeploy():
"""
Undeploy an application.
"""
info("Undeploying channel")
kubectl.delete(
f"--kustomize={config['repo']}/channel?ref={config['branch']}",
"--ignore-not-found",
context=env["hub"],
log=debug,
)
info("Undeploying application")
kubectl.delete(
f"--kustomize={config['repo']}/{config['path']}?ref={config['branch']}",
Expand Down

0 comments on commit 5783bde

Please sign in to comment.