Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Set type for all scale options #233

Merged
merged 3 commits into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import pytest
import sys
import distutils.util

log_level = os.getenv('TEST_LOG_LEVEL', 'INFO').upper()
log_levels = ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'EXCEPTION')
Expand All @@ -19,23 +18,25 @@


def pytest_addoption(parser):
parser.addoption('--masters', action='store', default=1,
parser.addoption('--masters', action='store', default=1, type=int,
help='Number of Jenkins masters to launch.')
parser.addoption('--jobs', action='store', default=1,
parser.addoption('--jobs', action='store', default=1, type=int,
help='Number of test jobs to launch.')
parser.addoption('--single-use', action='store', default=False,
help='Use Mesos Single-Use agents')
type=bool, help='Use Mesos Single-Use agents')
parser.addoption('--run-delay', action='store', default=1,
help='Run job every X minutes.')
type=int, help='Run job every X minutes.')
parser.addoption('--cpu-quota', action='store', default=0.0,
type=float,
help='CPU quota to set. 0.0 to set no quota.')
parser.addoption('--work-duration', action='store', default=600,
type=int,
help='Duration, in seconds, for the workload to '
'last (sleep).')
parser.addoption('--mom', action='store', default='',
help='Marathon on Marathon instance name.')
parser.addoption('--external-volume', action='store', default=False,
help='Use rexray external volumes.')
type=bool, help='Use rexray external volumes.')
parser.addoption('--scenario', action='store', default='sleep',
help='Test scenario to run (sleep, buildmarathon) '
'(default: sleep).')
Expand All @@ -52,7 +53,7 @@ def job_count(request) -> int:


@pytest.fixture
def single_use(request) -> int:
def single_use(request) -> bool:
return request.config.getoption('--single-use')


Expand Down Expand Up @@ -83,7 +84,4 @@ def scenario(request) -> str:

@pytest.fixture
def external_volume(request) -> bool:
v = request.config.getoption('--external-volume')
if type(v) == bool:
return v
return bool(distutils.util.strtobool(v))
return request.config.getoption('--external-volume')
17 changes: 7 additions & 10 deletions tests/scale/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
$ PYTEST_ARGS="--masters=3 --jobs=10" ./test.sh -m scale jenkins
To specify a CPU quota (what JPMC does) then run:
$ PYTEST_ARGS="--masters=3 --jobs=10 --cpu-quota=10.0" ./test.sh -m scale jenkins
To enable single use:
$ PYTEST_ARGS="--masters=3 --jobs=10 --single-use" ./test.sh -m scale jenkins
And to clean-up a test run of Jenkins instances:
$ ./test.sh -m scalecleanup jenkins

Expand All @@ -16,12 +18,12 @@
* How often, in minutes, to run a job (--run-delay); this is used
to create a cron schedule: "*/run-delay * * * *"
* To enable or disable "Mesos Single-Use Agent"; this is a toggle
and applies to all jobs equally.
and applies to all jobs equally. (default: False)
* How long, in seconds, for a job to "work" (sleep)
(--work-duration)
* CPU quota (--cpu-quota); 0.0 to disable / no quota
* To enable or disable External Volumes (--external-volume);
this uses rexray
this uses rexray (default: False)
* What test scenario to run (--scenario); supported values:
- sleep (sleep for --work-duration)
- buildmarathon (build the open source marathon project)
Expand All @@ -47,12 +49,12 @@
@pytest.mark.scale
def test_scaling_load(master_count,
job_count,
single_use,
single_use: bool,
run_delay,
cpu_quota,
work_duration,
mom,
external_volume,
external_volume: bool,
scenario):
"""Launch a load test scenario. This does not verify the results
of the test, but does ensure the instances and jobs were created.
Expand Down Expand Up @@ -211,12 +213,7 @@ def _launch_jobs(service_name: str,
label: Mesos label for jobs to use
"""
job_name = 'generator-job'

single_use_str = '100'
if not single or (
type(single) == str and single.lower() == 'false'
):
single_use_str = '0'
single_use_str = '100' if single else '0'

seed_config_xml = jenkins._get_job_fixture('gen-job.xml')
seed_config_str = ElementTree.tostring(
Expand Down