Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
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
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
1bd035a0
Commit
1bd035a0
authored
1 year ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
CI/CD pipeline - OFC'22 added code to kill test after 2 minutes
parent
be41ac90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!235
Release TeraFlowSDN 3.0
,
!216
Resolve "Automate end-to-end tests and integrate them in CI/CD pipeline"
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tests/ofc22/Dockerfile
+1
-1
1 addition, 1 deletion
src/tests/ofc22/Dockerfile
src/tests/ofc22/tests/conftest.py
+63
-0
63 additions, 0 deletions
src/tests/ofc22/tests/conftest.py
with
64 additions
and
1 deletion
src/tests/ofc22/Dockerfile
+
1
−
1
View file @
1bd035a0
...
@@ -93,7 +93,7 @@ export PYTHONPATH=/var/teraflow
...
@@ -93,7 +93,7 @@ export PYTHONPATH=/var/teraflow
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_bootstrap.py --junitxml=/opt/results/report_bootstrap.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_bootstrap.py --junitxml=/opt/results/report_bootstrap.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_create_service.py --junitxml=/opt/results/report_create_service.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_create_service.py --junitxml=/opt/results/report_create_service.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_delete_service.py --junitxml=/opt/results/report_delete_service.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_delete_service.py --junitxml=/opt/results/report_delete_service.xml
pytest --verbose --log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_cleanup.py --junitxml=/opt/results/report_cleanup.xml
pytest --verbose
--timeout=120
--log-level=INFO /var/teraflow/tests/ofc22/tests/test_functional_cleanup.py --junitxml=/opt/results/report_cleanup.xml
EOF
EOF
RUN
chmod
ug+x ./run_tests.sh
RUN
chmod
ug+x ./run_tests.sh
...
...
This diff is collapsed.
Click to expand it.
src/tests/ofc22/tests/conftest.py
0 → 100644
+
63
−
0
View file @
1bd035a0
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Acknowledgement: https://stackoverflow.com/questions/46766899/pytest-timeout-fail-test-instead-killing-whole-test-run
import
pytest
,
signal
class
Termination
(
SystemExit
):
pass
class
TimeoutExit
(
BaseException
):
pass
def
_terminate
(
signum
,
frame
):
raise
Termination
(
"
Runner is terminated from outside.
"
)
def
_timeout
(
signum
,
frame
):
raise
TimeoutExit
(
"
Runner timeout is reached, runner is terminating.
"
)
@pytest.hookimpl
def
pytest_addoption
(
parser
):
parser
.
addoption
(
'
--timeout
'
,
action
=
'
store
'
,
dest
=
'
timeout
'
,
type
=
int
,
default
=
None
,
help
=
"
number of seconds before each test failure
"
)
@pytest.hookimpl
def
pytest_configure
(
config
):
# Install the signal handlers that we want to process.
signal
.
signal
(
signal
.
SIGTERM
,
_terminate
)
signal
.
signal
(
signal
.
SIGALRM
,
_timeout
)
@pytest.hookimpl
(
hookwrapper
=
True
)
def
pytest_runtest_protocol
(
item
,
nextitem
):
# Set the per-test timeout (an alarm signal).
if
item
.
config
.
option
.
timeout
is
not
None
:
signal
.
alarm
(
item
.
config
.
option
.
timeout
)
try
:
# Run the setup, test body, and teardown stages.
yield
finally
:
# Disable the alarm when the test passes or fails.
# I.e. when we get into the framework's body.
signal
.
alarm
(
0
)
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