Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
09f1f7cc
Commit
09f1f7cc
authored
6 years ago
by
Finn
Browse files
Options
Downloads
Patches
Plain Diff
Updating unittests for cancellation of operation.
parent
cfd36752
No related branches found
No related tags found
Loading
Pipeline
#35094634
passed
6 years ago
Stage: test
Stage: post
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/integration/operations_service.py
+19
-4
19 additions, 4 deletions
tests/integration/operations_service.py
with
19 additions
and
4 deletions
tests/integration/operations_service.py
+
19
−
4
View file @
09f1f7cc
...
@@ -24,6 +24,7 @@ import grpc
...
@@ -24,6 +24,7 @@ import grpc
from
grpc._server
import
_Context
from
grpc._server
import
_Context
import
pytest
import
pytest
from
buildgrid._enums
import
OperationStage
from
buildgrid._exceptions
import
InvalidArgumentError
from
buildgrid._exceptions
import
InvalidArgumentError
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
from
buildgrid._protos.google.longrunning
import
operations_pb2
from
buildgrid._protos.google.longrunning
import
operations_pb2
...
@@ -236,12 +237,26 @@ def test_delete_operation_fail(instance, context):
...
@@ -236,12 +237,26 @@ def test_delete_operation_fail(instance, context):
context
.
set_code
.
assert_called_once_with
(
grpc
.
StatusCode
.
INVALID_ARGUMENT
)
context
.
set_code
.
assert_called_once_with
(
grpc
.
StatusCode
.
INVALID_ARGUMENT
)
def
test_cancel_operation
(
instance
,
context
):
def
test_cancel_operation
(
instance
,
controller
,
execute_request
,
context
):
response_execute
=
controller
.
execution_instance
.
execute
(
execute_request
.
action_digest
,
execute_request
.
skip_cache_lookup
)
request
=
operations_pb2
.
CancelOperationRequest
()
request
=
operations_pb2
.
CancelOperationRequest
()
request
.
name
=
"
{}/{}
"
.
format
(
instance_name
,
"
runner
"
)
request
.
name
=
"
{}/{}
"
.
format
(
instance_name
,
response_execute
.
name
)
instance
.
CancelOperation
(
request
,
context
)
instance
.
CancelOperation
(
request
,
context
)
context
.
set_code
.
assert_called_once_with
(
grpc
.
StatusCode
.
UNIMPLEMENTED
)
context
.
set_code
.
assert_called_once_with
(
grpc
.
StatusCode
.
CANCELLED
)
request
=
operations_pb2
.
ListOperationsRequest
(
name
=
instance_name
)
response
=
instance
.
ListOperations
(
request
,
context
)
assert
len
(
response
.
operations
)
is
1
for
operation
in
response
.
operations
:
operation_metadata
=
remote_execution_pb2
.
ExecuteOperationMetadata
()
operation
.
metadata
.
Unpack
(
operation_metadata
)
assert
operation_metadata
.
stage
==
OperationStage
.
COMPLETED
.
value
def
test_cancel_operation_blank
(
blank_instance
,
context
):
def
test_cancel_operation_blank
(
blank_instance
,
context
):
...
@@ -249,7 +264,7 @@ def test_cancel_operation_blank(blank_instance, context):
...
@@ -249,7 +264,7 @@ def test_cancel_operation_blank(blank_instance, context):
request
.
name
=
"
runner
"
request
.
name
=
"
runner
"
blank_instance
.
CancelOperation
(
request
,
context
)
blank_instance
.
CancelOperation
(
request
,
context
)
context
.
set_code
.
assert_called_once_with
(
grpc
.
StatusCode
.
UNIMPLE
MENT
ED
)
context
.
set_code
.
assert_called_once_with
(
grpc
.
StatusCode
.
INVALID_ARGU
MENT
)
def
test_cancel_operation_instance_fail
(
instance
,
context
):
def
test_cancel_operation_instance_fail
(
instance
,
context
):
...
...
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