Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Compare revisions
61934261bfe64c1882349d941f2b19652f06dd78 to 44ae17cf3ecf93855bea466e6a24abda400caa2c
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
arkindex/backend
Select target project
No results found
44ae17cf3ecf93855bea466e6a24abda400caa2c
Select Git revision
Swap
Target
arkindex/backend
Select target project
arkindex/backend
1 result
61934261bfe64c1882349d941f2b19652f06dd78
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Allow agents to update tasks from Stopping to Error
· 68ab41b0
Erwan Rouchet
authored
1 year ago
and
Bastien Abadie
committed
1 year ago
68ab41b0
Version 1.5.4-rc1
· 44ae17cf
Bastien Abadie
authored
1 year ago
44ae17cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
VERSION
+1
-1
1 addition, 1 deletion
VERSION
arkindex/ponos/serializers.py
+3
-2
3 additions, 2 deletions
arkindex/ponos/serializers.py
arkindex/ponos/tests/test_api.py
+82
-14
82 additions, 14 deletions
arkindex/ponos/tests/test_api.py
with
86 additions
and
17 deletions
VERSION
View file @
44ae17cf
1.5.4-
beta
1
1.5.4-
rc
1
This diff is collapsed.
Click to expand it.
arkindex/ponos/serializers.py
View file @
44ae17cf
...
...
@@ -106,6 +106,7 @@ class TaskLightSerializer(serializers.ModelSerializer):
└⟶ Error ├⟶ Failed
└⟶ Error
Stopping ⟶ Stopped
└⟶ Error
"""
).
strip
(),
)
...
...
@@ -133,8 +134,8 @@ class TaskLightSerializer(serializers.ModelSerializer):
allowed_transitions
=
{
State
.
Unscheduled
:
[
State
.
Pending
],
State
.
Pending
:
[
State
.
Running
,
State
.
Error
],
State
.
Running
:
[
State
.
Completed
,
State
.
Failed
,
State
.
Stopping
,
State
.
Error
],
State
.
Stopping
:
[
State
.
Stopped
],
State
.
Running
:
[
State
.
Completed
,
State
.
Failed
,
State
.
Error
],
State
.
Stopping
:
[
State
.
Stopped
,
State
.
Error
],
}
if
self
.
instance
and
state
not
in
allowed_transitions
.
get
(
self
.
instance
.
state
,
[]):
raise
ValidationError
(
f
"
Transition from state
{
self
.
instance
.
state
}
to state
{
state
}
is forbidden.
"
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/ponos/tests/test_api.py
View file @
44ae17cf
...
...
@@ -1275,25 +1275,93 @@ class TestAPI(FixtureAPITestCase):
self
.
assertEqual
(
self
.
task1
.
state
,
state
)
@patch
(
"
arkindex.ponos.models.TaskLogs.latest
"
,
new_callable
=
PropertyMock
)
def
test_partial_update_task_from_agent
(
self
,
short_logs_mock
):
@patch
(
"
arkindex.ponos.tasks.notify_process_completion.delay
"
)
def
test_partial_update_task_from_agent_allowed_states
(
self
,
notify_mock
,
short_logs_mock
):
short_logs_mock
.
return_value
=
""
self
.
task1
.
state
=
State
.
Pending
self
.
task1
.
agent
=
self
.
agent
self
.
task1
.
save
()
with
self
.
assertNumQueries
(
5
):
resp
=
self
.
client
.
patch
(
reverse
(
"
api:task-details
"
,
args
=
[
self
.
task1
.
id
]),
data
=
{
"
state
"
:
State
.
Running
.
value
},
HTTP_AUTHORIZATION
=
f
"
Bearer
{
self
.
agent
.
token
.
access_token
}
"
,
)
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_200_OK
)
cases
=
[
(
State
.
Unscheduled
,
State
.
Pending
,
5
),
(
State
.
Pending
,
State
.
Running
,
5
),
(
State
.
Pending
,
State
.
Error
,
11
),
(
State
.
Running
,
State
.
Completed
,
9
),
(
State
.
Running
,
State
.
Failed
,
9
),
(
State
.
Running
,
State
.
Error
,
9
),
(
State
.
Stopping
,
State
.
Stopped
,
9
),
(
State
.
Stopping
,
State
.
Error
,
9
),
]
for
from_state
,
to_state
,
query_count
in
cases
:
with
self
.
subTest
(
from_state
=
from_state
,
to_state
=
to_state
):
self
.
task1
.
state
=
from_state
self
.
task1
.
save
()
data
=
resp
.
json
()
self
.
assertEqual
(
data
[
"
id
"
],
str
(
self
.
task1
.
id
))
self
.
assertEqual
(
data
[
"
state
"
],
State
.
Running
.
value
)
self
.
task1
.
refresh_from_db
()
self
.
assertEqual
(
self
.
task1
.
state
,
State
.
Running
)
with
self
.
assertNumQueries
(
query_count
):
resp
=
self
.
client
.
patch
(
reverse
(
"
api:task-details
"
,
args
=
[
self
.
task1
.
id
]),
data
=
{
"
state
"
:
to_state
.
value
},
HTTP_AUTHORIZATION
=
f
"
Bearer
{
self
.
agent
.
token
.
access_token
}
"
,
)
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_200_OK
)
data
=
resp
.
json
()
self
.
assertEqual
(
data
[
"
id
"
],
str
(
self
.
task1
.
id
))
self
.
assertEqual
(
data
[
"
state
"
],
to_state
.
value
)
self
.
task1
.
refresh_from_db
()
self
.
assertEqual
(
self
.
task1
.
state
,
to_state
)
def
test_partial_update_task_from_agent_forbidden_states
(
self
):
self
.
task1
.
agent
=
self
.
agent
self
.
task1
.
save
()
cases
=
[
(
State
.
Unscheduled
,
State
.
Running
),
(
State
.
Unscheduled
,
State
.
Completed
),
(
State
.
Unscheduled
,
State
.
Failed
),
(
State
.
Unscheduled
,
State
.
Error
),
(
State
.
Unscheduled
,
State
.
Stopping
),
(
State
.
Unscheduled
,
State
.
Stopped
),
(
State
.
Pending
,
State
.
Unscheduled
),
(
State
.
Pending
,
State
.
Completed
),
(
State
.
Pending
,
State
.
Failed
),
(
State
.
Pending
,
State
.
Stopping
),
(
State
.
Pending
,
State
.
Stopped
),
(
State
.
Running
,
State
.
Unscheduled
),
(
State
.
Running
,
State
.
Pending
),
(
State
.
Running
,
State
.
Stopping
),
(
State
.
Running
,
State
.
Stopped
),
(
State
.
Stopping
,
State
.
Unscheduled
),
(
State
.
Stopping
,
State
.
Pending
),
(
State
.
Stopping
,
State
.
Running
),
(
State
.
Stopping
,
State
.
Completed
),
(
State
.
Stopping
,
State
.
Failed
),
# Cannot go from one state to the same state
*
((
state
,
state
)
for
state
in
State
),
# Cannot go from a final state to anywhere
*
((
final_state
,
state
)
for
final_state
in
FINAL_STATES
for
state
in
State
),
]
for
from_state
,
to_state
in
cases
:
with
self
.
subTest
(
from_state
=
from_state
,
to_state
=
to_state
):
self
.
task1
.
state
=
from_state
self
.
task1
.
save
()
with
self
.
assertNumQueries
(
2
):
resp
=
self
.
client
.
put
(
reverse
(
"
api:task-details
"
,
args
=
[
self
.
task1
.
id
]),
data
=
{
"
state
"
:
to_state
.
value
},
HTTP_AUTHORIZATION
=
f
"
Bearer
{
self
.
agent
.
token
.
access_token
}
"
,
)
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertDictEqual
(
resp
.
json
(),
{
"
state
"
:
[
f
"
Transition from state
{
from_state
}
to state
{
to_state
}
is forbidden.
"
]},
)
self
.
task1
.
refresh_from_db
()
self
.
assertEqual
(
self
.
task1
.
state
,
from_state
)
def
test_partial_update_task_from_agent_requires_login
(
self
):
with
self
.
assertNumQueries
(
0
):
...
...
This diff is collapsed.
Click to expand it.