Skip to content
Snippets Groups Projects
Commit 41921454 authored by Georges Racinet's avatar Georges Racinet
Browse files

Wrapper script to run smoke tests on Clever prod servers

Simple shell wrapper scripts have been sitting on my computers for a
long time, here is a version for both instances, with the credentials
singled out as environment variables or user input.

This is to be run with the working copy updated to the relevant branch
(`default`, `stable` or `oldstable`) for the target platform. Reasons:

- the functional tests have to be adapted upon minor GitLab version
  changes (not systematic, yet frequent enough)
- we might have different options to provide in the wrapper script itself
  depending on Heptapod specifics (native mode would be a prime example of
  that).

Note: at the time of deployment of Heptapod 0.30.0 on both platforms, the
stable branch is outdated, and the default branch is for Heptapod 0.30.

I've hesitated a bit between one single script for foss.h.n and
heptapod.host or two scripts, because there have been times in the
past when there were more differences than the login sequence. With
a Python script, we can manage such differences in the future anyway.

The reason to bite the bullet and make a full Python script is the
usual one: as long as there is at least an argument, chances that
someone would call it with `--help` are high.

A full pipeline would be a waste of resources with this, the only
relevant part being only flake8 for the new script.
[skip ci]
parent 8f564141
No related branches found
No related tags found
3 merge requests!164Validation of Heptapod 0.35.1,!130heptapod#658: making Heptapod 0.30 the new stable,!128Wrapper script to run smoke tests on Clever prod servers
Checking pipeline status
......@@ -16,7 +16,7 @@
image: registry.heptapod.net/heptapod/ci-images/fixed-pydeps
script:
- flake8 --version
- flake8 tests conftest.py
- flake8 tests conftest.py smoke-tests-prod-clever-cloud
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "push"'
......
#!/usr/bin/env python3
import argparse
from getpass import getpass
import os
CREDS_ENVIRON = 'SMOKE_TESTS_HEPTAPOD_CREDENTIALS'
creds = os.environ.get(CREDS_ENVIRON)
parser = argparse.ArgumentParser(
description="Wrapper script to launch the subset of tests adapted "
"to production servers with the right options for instances "
"hosted on Clever Cloud. "
"Credentials can be provided in the {CREDS_ENVIRON} environment variable"
"or at the prompt")
parser.add_argument('target', choices=('foss', 'host'))
parser.add_argument('--retry-failed', '--lf',
help="Retry failed tests of previous invocation")
cl_args = parser.parse_args()
if not creds:
creds = getpass(
prompt='Please enter the full credentials string: ').strip()
if not creds:
raise RuntimeError("Empty credentials")
target = cl_args.target
if target == 'foss':
target_url = 'https://foss.heptapod.net'
elif target == 'host':
target_url = 'https://heptapod.host'
base_dir = os.path.dirname(__file__)
# if the cache is still valid as seen from here`, chances that tokens
# are expired are very high. Generally speaking, better to start afresh
# to avoid various confusing problems.
cache_path = os.path.join(base_dir, 'tests', 'data', 'instance.cache')
if os.path.exists(cache_path):
os.unlink(cache_path)
env = dict(os.environ)
env['HDK_HEPTAPOD_TESTS_BASEPYTHON'] = 'python3.9'
# Using the 'hdk' tox environment just to force the Python version
# gracinet: probably not so much necessary nowadays, but it used to make
# a difference before the tests became ready to run Python 3.9.
# I don't think anyone ever tried Python 3.10 yet.
cmd = ['tox', '-e', 'hdk', '--',
'--heptapod-prod-server',
'--heptapod-url', target_url,
'--heptapod-prod-group-owner-credentials', creds,
'--heptapod-ssh-port', '22',
'--heptapod-ssh-user', 'hg',
'--heptapod-hg-native', 'full']
if target == 'host':
cmd.append('--heptapod-clever-cloud-sso')
if cl_args.retry_failed:
cmd.append('--lf')
os.execvpe('tox', cmd, env)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment