Skip to content

Commit

Permalink
test: add tests for CVAT
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioHeredia committed Sep 26, 2024
1 parent 43924db commit 49fd728
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ai4papi/nomad/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def get_deployment(
# Something happened, job didn't deploy (eg. job needs port that's currently being used)
# We have to return `placement failures message`.
info['status'] = 'error'
info['error_msg'] = f"{evals[0]['FailedTGAllocs']}"
info['error_msg'] = f"{evals[0].get('FailedTGAllocs', '')}"

else:
# info['error_msg'] = f"Job has not been yet evaluated. Contact with support sharing your job ID: {j['ID']}."
Expand Down
7 changes: 6 additions & 1 deletion tests/deployments/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
assert isinstance(rcreate, dict)
assert 'job_ID' in rcreate.keys()

time.sleep(0.2) # Nomad takes some time to allocate deployment

# Retrieve that module
rdep = modules.get_deployment(
vo='vo.ai4eosc.eu',
Expand All @@ -40,6 +42,7 @@
assert isinstance(rdep, dict)
assert 'job_ID' in rdep.keys()
assert rdep['job_ID']==rcreate['job_ID']
assert rdep['status']!='error'

# Retrieve all modules
rdeps = modules.get_deployments(
Expand All @@ -50,6 +53,7 @@
)
assert isinstance(rdeps, list)
assert any([d['job_ID']==rcreate['job_ID'] for d in rdeps])
assert all([d['job_ID']!='error' for d in rdeps])

# Check that we cannot retrieve that module from tools
# This should break!
Expand Down Expand Up @@ -79,10 +83,11 @@
credentials=token
),
)
time.sleep(3) # Nomad takes some time to delete
assert isinstance(rdel, dict)
assert 'status' in rdel.keys()

time.sleep(3) # Nomad takes some time to delete

# Check module no longer exists
rdeps3 = modules.get_deployments(
vos=['vo.ai4eosc.eu'],
Expand Down
54 changes: 53 additions & 1 deletion tests/deployments/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
that ENV variable.'
)

print(' Testing FL server')

# Create tool
rcreate = tools.create_deployment(
vo='vo.ai4eosc.eu',
Expand All @@ -30,6 +32,8 @@
assert isinstance(rcreate, dict)
assert 'job_ID' in rcreate.keys()

time.sleep(0.2) # Nomad takes some time to allocate deployment

# Retrieve that tool
rdep = tools.get_deployment(
vo='vo.ai4eosc.eu',
Expand All @@ -41,6 +45,7 @@
assert isinstance(rdep, dict)
assert 'job_ID' in rdep.keys()
assert rdep['job_ID']==rcreate['job_ID']
assert rdep['status']!='error'

# Retrieve all tools
rdeps = tools.get_deployments(
Expand All @@ -51,6 +56,7 @@
)
assert isinstance(rdeps, list)
assert any([d['job_ID']==rcreate['job_ID'] for d in rdeps])
assert all([d['job_ID']!='error' for d in rdeps])

# Check that we cannot retrieve that tool from modules
# This should break!
Expand Down Expand Up @@ -80,10 +86,11 @@
credentials=token
),
)
time.sleep(3) # Nomad takes some time to delete
assert isinstance(rdel, dict)
assert 'status' in rdel.keys()

time.sleep(3) # Nomad takes some time to delete

# Check tool no longer exists
rdeps3 = tools.get_deployments(
vos=['vo.ai4eosc.eu'],
Expand All @@ -93,4 +100,49 @@
)
assert not any([d['job_ID']==rcreate['job_ID'] for d in rdeps3])

############################################################
# Additionally test simply the creation of the other tools #
############################################################

print(' Testing CVAT')

# Create tool
rcreate = tools.create_deployment(
vo='vo.ai4eosc.eu',
tool_name='ai4os-cvat',
conf={
'general':{
'title': 'CVAT test',
'cvat_username': 'mock_user',
'cvat_password': 'mock_password',
},
'storage': {
'rclone_conf': '/srv/.rclone/rclone.conf',
'rclone_url': 'https://share.services.ai4os.eu/remote.php/webdav',
'rclone_vendor': 'nextcloud',
'rclone_user': 'mock_user',
'rclone_password': 'mock_password',
}
},
authorization=SimpleNamespace(
credentials=token
),
)
assert isinstance(rcreate, dict)
assert 'job_ID' in rcreate.keys()
assert rdep['status']!='error'

time.sleep(0.2) # Nomad takes some time to allocate deployment

# Delete tool
rdel = tools.delete_deployment(
vo='vo.ai4eosc.eu',
deployment_uuid=rcreate['job_ID'],
authorization=SimpleNamespace(
credentials=token
),
)
assert isinstance(rdel, dict)
assert 'status' in rdel.keys()

print('Deployments (tools) tests passed!')

0 comments on commit 49fd728

Please sign in to comment.