Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Tasks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Arkindex
Tasks
Commits
b0d2a8c7
Commit
b0d2a8c7
authored
1 year ago
by
Erwan Rouchet
Committed by
Bastien Abadie
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove process_id parameter from CreateTask in Git imports
parent
63cf5199
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!355
Remove process_id parameter from CreateTask in Git imports
Pipeline
#21511
passed
1 year ago
Stage: release
Changes
2
Pipelines
6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_tasks/import_git/worker.py
+2
-10
2 additions, 10 deletions
arkindex_tasks/import_git/worker.py
tests/import_git/test_worker.py
+7
-40
7 additions, 40 deletions
tests/import_git/test_worker.py
with
9 additions
and
50 deletions
arkindex_tasks/import_git/worker.py
+
2
−
10
View file @
b0d2a8c7
...
...
@@ -80,10 +80,6 @@ class GitWorkerImport(object):
"""
assert
isinstance
(
versions
,
(
set
,
list
))
assert
len
(
versions
)
>
0
,
"
No versions
"
assert
"
ARKINDEX_PROCESS_ID
"
in
os
.
environ
,
(
"
Missing ARKINDEX_PROCESS_ID environment variable
"
"
to create a build task for this worker version
"
)
assert
"
PONOS_TASK
"
in
os
.
environ
,
(
"
Missing PONOS_TASK environment variable
"
"
to create a build task for this worker version
"
...
...
@@ -106,7 +102,6 @@ class GitWorkerImport(object):
default_client
.
request
(
"
CreateTask
"
,
body
=
{
"
process_id
"
:
os
.
environ
[
"
ARKINDEX_PROCESS_ID
"
],
"
slug
"
:
f
"
docker_build_
{
slug
}
"
,
"
parents
"
:
[
os
.
environ
[
"
PONOS_TASK
"
]],
"
image
"
:
f
"
registry.gitlab.com/teklia/arkindex/tasks:
{
__version__
}
"
,
...
...
@@ -146,17 +141,14 @@ class GitWorkerImport(object):
try
:
worker
=
self
.
create_worker
(
worker_config
)
version
=
self
.
create_worker_version
(
worker
,
worker_config
)
if
(
"
ARKINDEX_PROCESS_ID
"
in
os
.
environ
and
"
PONOS_TASK
"
in
os
.
environ
):
if
"
PONOS_TASK
"
in
os
.
environ
:
# Index worker version per its dockerfile
dockerfile
=
worker_config
[
"
docker
"
][
"
build
"
]
or
"
Dockerfile
"
dockerfiles
[
dockerfile
].
add
(
version
[
"
id
"
])
else
:
logger
.
warning
(
"
Couldn
'
t create build task for this worker version since we aren
'
t in a
"
"
ponos context: Missing
ARKINDEX_PROCESS_ID and/or
PONOS_TASK environment variable
s
"
"
ponos context: Missing PONOS_TASK environment variable
"
)
except
Exception
as
e
:
failed_config
+=
1
...
...
This diff is collapsed.
Click to expand it.
tests/import_git/test_worker.py
+
7
−
40
View file @
b0d2a8c7
...
...
@@ -327,7 +327,7 @@ class TestWorker(TestCase):
],
)
def
test_create_build_task_missing_p
rocess_id
_var
(
self
,
req_mock
):
def
test_create_build_task_missing_p
onos_task
_var
(
self
,
req_mock
):
repo_id
=
uuid4
()
rev_id
=
uuid4
()
version_id
=
uuid4
()
...
...
@@ -338,34 +338,13 @@ class TestWorker(TestCase):
with
self
.
assertRaises
(
AssertionError
,
msg
=
"
Missing
ARKINDEX_PROCESS_ID
environment variable
"
msg
=
"
Missing
PONOS_TASK
environment variable
"
"
to create a build task for this worker version
"
,
):
git_worker_import
.
create_build_task
(
"
book_of_hours
"
,
[
version_id
])
self
.
assertEqual
(
req_mock
.
call_count
,
0
)
def
test_create_build_task_missing_ponos_task_var
(
self
,
req_mock
):
repo_id
=
uuid4
()
rev_id
=
uuid4
()
version_id
=
uuid4
()
git_worker_import
=
GitWorkerImport
(
repository_id
=
repo_id
,
revision_id
=
rev_id
,
config
=
self
.
config_worker
)
with
patch
.
dict
(
"
arkindex_tasks.base.os.environ
"
,
{
"
ARKINDEX_PROCESS_ID
"
:
str
(
uuid4
())}
):
with
self
.
assertRaises
(
AssertionError
,
msg
=
"
Missing PONOS_TASK environment variable
"
"
to create a build task for this worker version
"
,
):
git_worker_import
.
create_build_task
(
"
book_of_hours
"
,
[
version_id
])
self
.
assertEqual
(
req_mock
.
call_count
,
0
)
def
test_create_build_task
(
self
,
req_mock
):
repo_id
=
uuid4
()
rev_id
=
uuid4
()
...
...
@@ -376,10 +355,9 @@ class TestWorker(TestCase):
with
patch
.
dict
(
"
arkindex_tasks.base.os.environ
"
,
{
"
ARKINDEX_PROCESS_ID
"
:
str
(
uuid4
()),
"
PONOS_TASK
"
:
str
(
uuid4
())},
{
"
PONOS_TASK
"
:
str
(
uuid4
())},
):
payload
=
{
"
process_id
"
:
os
.
environ
[
"
ARKINDEX_PROCESS_ID
"
],
"
slug
"
:
"
docker_build_book_of_hours
"
,
"
parents
"
:
[
os
.
environ
[
"
PONOS_TASK
"
]],
"
image
"
:
f
"
registry.gitlab.com/teklia/arkindex/tasks:
{
tasks_version
}
"
,
...
...
@@ -405,9 +383,7 @@ class TestWorker(TestCase):
[(
"
POST
"
,
"
https://arkindex.teklia.com/api/v1/task/
"
,
payload
)],
)
@patch.dict
(
"
os.environ
"
,
{
"
ARKINDEX_PROCESS_ID
"
:
str
(
uuid4
()),
"
PONOS_TASK
"
:
str
(
uuid4
())}
)
@patch.dict
(
"
os.environ
"
,
{
"
PONOS_TASK
"
:
str
(
uuid4
())})
def
test_run
(
self
,
req_mock
):
repo_id
,
rev_id
,
worker_id
,
version_id
=
(
str
(
uuid4
()),
...
...
@@ -482,7 +458,6 @@ class TestWorker(TestCase):
"
POST
"
,
"
https://arkindex.teklia.com/api/v1/task/
"
,
{
"
process_id
"
:
os
.
environ
[
"
ARKINDEX_PROCESS_ID
"
],
"
slug
"
:
"
docker_build_dockerfile1
"
,
"
parents
"
:
[
os
.
environ
[
"
PONOS_TASK
"
]],
"
image
"
:
f
"
registry.gitlab.com/teklia/arkindex/tasks:
{
tasks_version
}
"
,
...
...
@@ -493,9 +468,7 @@ class TestWorker(TestCase):
],
)
@patch.dict
(
"
os.environ
"
,
{
"
ARKINDEX_PROCESS_ID
"
:
str
(
uuid4
()),
"
PONOS_TASK
"
:
str
(
uuid4
())}
)
@patch.dict
(
"
os.environ
"
,
{
"
PONOS_TASK
"
:
str
(
uuid4
())})
def
test_run_worker_error
(
self
,
req_mock
):
"""
A single failure when creating any worker should cause the import to fail
...
...
@@ -592,9 +565,7 @@ class TestWorker(TestCase):
],
)
@patch.dict
(
"
os.environ
"
,
{
"
ARKINDEX_PROCESS_ID
"
:
str
(
uuid4
()),
"
PONOS_TASK
"
:
str
(
uuid4
())}
)
@patch.dict
(
"
os.environ
"
,
{
"
PONOS_TASK
"
:
str
(
uuid4
())})
def
test_run_worker_version_error
(
self
,
req_mock
):
"""
A single failure when creating any worker should cause the import to fail
...
...
@@ -711,9 +682,7 @@ class TestWorker(TestCase):
],
)
@patch.dict
(
"
os.environ
"
,
{
"
ARKINDEX_PROCESS_ID
"
:
str
(
uuid4
()),
"
PONOS_TASK
"
:
str
(
uuid4
())}
)
@patch.dict
(
"
os.environ
"
,
{
"
PONOS_TASK
"
:
str
(
uuid4
())})
def
test_run_task_error
(
self
,
req_mock
):
repo_id
,
rev_id
,
worker1_id
,
worker2_id
,
version1_id
,
version2_id
=
(
str
(
uuid4
()),
...
...
@@ -841,7 +810,6 @@ class TestWorker(TestCase):
"
POST
"
,
"
https://arkindex.teklia.com/api/v1/task/
"
,
{
"
process_id
"
:
os
.
environ
[
"
ARKINDEX_PROCESS_ID
"
],
"
slug
"
:
"
docker_build_dockerfile1
"
,
"
parents
"
:
[
os
.
environ
[
"
PONOS_TASK
"
]],
"
image
"
:
f
"
registry.gitlab.com/teklia/arkindex/tasks:
{
tasks_version
}
"
,
...
...
@@ -853,7 +821,6 @@ class TestWorker(TestCase):
"
POST
"
,
"
https://arkindex.teklia.com/api/v1/task/
"
,
{
"
process_id
"
:
os
.
environ
[
"
ARKINDEX_PROCESS_ID
"
],
"
slug
"
:
"
docker_build_dockerfile2
"
,
"
parents
"
:
[
os
.
environ
[
"
PONOS_TASK
"
]],
"
image
"
:
f
"
registry.gitlab.com/teklia/arkindex/tasks:
{
tasks_version
}
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment