-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow listing/deleting try-me (#68)
* feat: allow listing/deleting try-me * feat: add titles to try-me deployments
- Loading branch information
1 parent
17563f5
commit 6fa977a
Showing
4 changed files
with
183 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import os | ||
import time | ||
from types import SimpleNamespace | ||
|
||
from ai4papi.routers.v1.try_me import nomad | ||
|
||
|
||
# Retrieve EGI token (not generated on the fly in case the are rate limiting issues | ||
# if too many queries) | ||
token = os.getenv('TMP_EGI_TOKEN') | ||
if not token: | ||
raise Exception( | ||
'Please remember to set a token as ENV variable before executing \ | ||
the tests! \n\n \ | ||
export TMP_EGI_TOKEN="$(oidc-token egi-checkin)" \n\n \ | ||
If running from VScode make sure to launch `code` from that terminal so it can access \ | ||
that ENV variable.' | ||
) | ||
|
||
# Create deployment | ||
rcreate = nomad.create_deployment( | ||
module_name="ai4os-demo-app", | ||
authorization=SimpleNamespace( | ||
credentials=token | ||
), | ||
) | ||
assert isinstance(rcreate, dict) | ||
assert 'job_ID' in rcreate.keys() | ||
|
||
# Retrieve that deployment | ||
rdep = nomad.get_deployment( | ||
deployment_uuid=rcreate['job_ID'], | ||
authorization=SimpleNamespace( | ||
credentials=token | ||
), | ||
) | ||
assert isinstance(rdep, dict) | ||
assert 'job_ID' in rdep.keys() | ||
assert rdep['job_ID']==rcreate['job_ID'] | ||
|
||
# Retrieve all deployments | ||
rdeps = nomad.get_deployments( | ||
authorization=SimpleNamespace( | ||
credentials=token | ||
), | ||
) | ||
assert isinstance(rdeps, list) | ||
assert any([d['job_ID']==rcreate['job_ID'] for d in rdeps]) | ||
|
||
# Delete deployment | ||
rdel = nomad.delete_deployment( | ||
deployment_uuid=rcreate['job_ID'], | ||
authorization=SimpleNamespace( | ||
credentials=token | ||
), | ||
) | ||
time.sleep(3) # Nomad takes some time to delete | ||
assert isinstance(rdel, dict) | ||
assert 'status' in rdel.keys() | ||
|
||
# Check module no longer exists | ||
rdeps3 = nomad.get_deployments( | ||
authorization=SimpleNamespace( | ||
credentials=token | ||
), | ||
) | ||
assert not any([d['job_ID']==rcreate['job_ID'] for d in rdeps3]) | ||
|
||
print('Try-me (nomad) tests passed!') |