Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
c7dd3503
Commit
c7dd3503
authored
Apr 05, 2020
by
Markus Scheidgen
Browse files
Full integration test for admin. Allow admin to delete published upload and dataset with doi.
parent
ad0325ee
Pipeline
#72280
passed with stages
in 21 minutes and 37 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
c7dd3503
...
...
@@ -104,7 +104,7 @@ deploy:
-
helm dependency update ops/helm/nomad
-
helm upgrade --namespace nomad --install $RELEASE_NAME ops/helm/nomad -f ops/helm/nomad/ci-dev-values.yaml --set proxy.external.path=/dev/nomad/$RELEASE_NAME,image.tag=$CI_COMMIT_REF_NAME,roll=true --wait
-
docker pull $TEST_IMAGE
-
docker run -t -e NOMAD_KEYCLOAK_REALM_NAME=fairdi_nomad_prod $TEST_IMAGE python -m nomad.cli client -n $CI_DEV_CLUSTER_PROXY/dev/nomad/$RELEASE_NAME/api -u admin -w $CI_NOMAD_ADMIN_PASSWORD integrationtests
--skip-doi
-
docker run -t -e NOMAD_KEYCLOAK_REALM_NAME=fairdi_nomad_prod $TEST_IMAGE python -m nomad.cli client -n $CI_DEV_CLUSTER_PROXY/dev/nomad/$RELEASE_NAME/api -u admin -w $CI_NOMAD_ADMIN_PASSWORD integrationtests
except
:
-
/^dev-.*$/
...
...
nomad/app/api/dataset.py
View file @
c7dd3503
...
...
@@ -175,7 +175,10 @@ class DatasetResource(Resource):
abort
(
404
,
'Dataset with name %s does not exist for current user'
%
name
)
if
result
.
doi
is
not
None
and
len
(
result
.
doi
)
>
0
:
abort
(
400
,
'Dataset with name %s has a DOI and cannot be deleted'
%
name
)
if
g
.
user
.
is_admin
:
DOI
.
objects
(
doi__in
=
result
.
doi
).
delete
()
else
:
abort
(
400
,
'Dataset with name %s has a DOI and cannot be deleted'
%
name
)
# edit all affected entries
edit
(
...
...
nomad/app/api/upload.py
View file @
c7dd3503
...
...
@@ -419,7 +419,7 @@ class UploadResource(Resource):
if
upload
.
user_id
!=
str
(
g
.
user
.
user_id
)
and
not
g
.
user
.
is_admin
:
abort
(
401
,
message
=
'Upload with id %s does not belong to you.'
%
upload_id
)
if
upload
.
published
:
if
upload
.
published
and
not
g
.
user
.
is_admin
:
abort
(
400
,
message
=
'The upload is already published'
)
if
upload
.
tasks_running
:
...
...
nomad/cli/client/client.py
View file @
c7dd3503
...
...
@@ -90,7 +90,8 @@ def handle_common_errors(func):
@
click
.
option
(
'-w'
,
'--password'
,
default
=
nomad_config
.
client
.
password
,
help
=
'the password used to login.'
)
@
click
.
option
(
'--no-ssl-verify'
,
help
=
'disables SSL verificaton when talking to nomad.'
,
is_flag
=
True
)
@
click
.
option
(
'--no-token'
,
is_flag
=
True
,
help
=
'replaces token with basic auth, e.g. to work with v0.6.x or older API versions'
)
def
client
(
url
:
str
,
user
:
str
,
password
:
str
,
no_ssl_verify
:
bool
,
no_token
:
bool
):
@
click
.
pass_context
def
client
(
ctx
,
url
:
str
,
user
:
str
,
password
:
str
,
no_ssl_verify
:
bool
,
no_token
:
bool
):
logger
=
utils
.
get_logger
(
__name__
)
logger
.
info
(
'Used nomad is %s'
%
url
)
...
...
@@ -98,6 +99,8 @@ def client(url: str, user: str, password: str, no_ssl_verify: bool, no_token: bo
nomad_config
.
client
.
url
=
url
ctx
.
obj
.
user
=
user
global
_create_client
def
_create_client
(
*
args
,
**
kwargs
):
# pylint: disable=W0612
...
...
nomad/cli/client/integrationtests.py
View file @
c7dd3503
...
...
@@ -183,11 +183,11 @@ def integrationtests(ctx, skip_parsers, skip_publish, skip_doi, skip_mirror):
assert
doi
has_doi
=
True
if
not
has_doi
:
if
not
has_doi
or
ctx
.
obj
.
user
==
'admin'
:
print
(
'deleting dataset'
)
result
=
client
.
datasets
.
delete_dataset
(
name
=
dataset
).
response
().
result
if
not
skip_mirror
:
if
not
skip_mirror
and
ctx
.
obj
.
user
==
'admin'
:
print
(
'getting upload mirror'
)
# get_upload_mirror gives 404
payload
=
dict
(
query
=
dict
(
upload_id
=
upload
.
upload_id
))
...
...
@@ -196,7 +196,7 @@ def integrationtests(ctx, skip_parsers, skip_publish, skip_doi, skip_mirror):
assert
len
(
client
.
mirror
.
get_upload_mirror
(
upload_id
=
upload
.
upload_id
).
response
().
result
.
calcs
)
>
0
finally
:
if
not
published
:
if
not
published
or
ctx
.
obj
.
user
==
'admin'
:
print
(
'delete the upload again'
)
client
.
uploads
.
delete_upload
(
upload_id
=
upload
.
upload_id
).
response
()
while
upload
.
process_running
:
...
...
nomad/processing/data.py
View file @
c7dd3503
...
...
@@ -625,14 +625,14 @@ class Upload(Proc):
'''
logger
=
self
.
get_logger
()
with
utils
.
lnr
(
logger
,
'
staged
upload delete failed'
):
with
utils
.
lnr
(
logger
,
'upload delete failed'
):
with
utils
.
timer
(
logger
,
'upload deleted from index'
,
step
=
'index'
,
upload_size
=
self
.
upload_files
.
size
):
search
.
delete_upload
(
self
.
upload_id
)
with
utils
.
timer
(
logger
,
'
staged
upload deleted'
,
step
=
'files'
,
logger
,
'upload deleted'
,
step
=
'files'
,
upload_size
=
self
.
upload_files
.
size
):
self
.
upload_files
.
delete
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment