Skip to content

Commit

Permalink
Add scenario configuration (mesosphere#231)
Browse files Browse the repository at this point in the history
Add a new scenario flag that can change workload. Most of the
functionality is in the Job DSL job.

Supported workloads:
- "sleep" - sleep for X seconds (--work-duration)
- "buildmarathon" - build the marathon project
  • Loading branch information
colin-msphere authored May 15, 2018
1 parent 12d9143 commit aff99dc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
15 changes: 14 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def pytest_addoption(parser):
help='Marathon on Marathon instance name.')
parser.addoption('--external-volume', action='store', default=False,
help='Use rexray external volumes.')
parser.addoption('--scenario', action='store', default='sleep',
help='Test scenario to run (sleep, buildmarathon) '
'(default: sleep).')


@pytest.fixture
Expand Down Expand Up @@ -67,10 +70,20 @@ def cpu_quota(request) -> float:
def work_duration(request) -> int:
return int(request.config.getoption('--work-duration'))


@pytest.fixture
def mom(request) -> str:
return request.config.getoption('--mom')


@pytest.fixture
def scenario(request) -> str:
return request.config.getoption('--scenario')


@pytest.fixture
def external_volume(request) -> bool:
return bool(distutils.util.strtobool(request.config.getoption('--external-volume')))
v = request.config.getoption('--external-volume')
if type(v) == bool:
return v
return bool(distutils.util.strtobool(v))
27 changes: 20 additions & 7 deletions testing/testData/gen-job.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<defaultValue>600</defaultValue>
<trim>false</trim>
</hudson.model.StringParameterDefinition>
<hudson.model.StringParameterDefinition>
<name>SCENARIO</name>
<description>Test scenario to run.</description>
<defaultValue>sleep</defaultValue>
<trim>true</trim>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
Expand Down Expand Up @@ -72,21 +78,28 @@
if (singleP == 100 || (singleP != 0 &amp;&amp; Math.abs(random.nextInt() % 100) + 1 &lt;= singleP)) {
configure { node -&gt;
node / &apos;buildWrappers&apos; / &apos;org.jenkinsci.plugins.mesos.MesosSingleUseSlave&apos;()
}
}
}

scm {
git {
remote {
name(&apos;origin&apos;)
url(&apos;https://github.com/mesosphere/marathon.git&apos;)
if (SCENARIO == &quot;buildmarathon&quot;) {
scm {
git {
remote {
name(&apos;origin&apos;)
url(&apos;https://github.com/mesosphere/marathon.git&apos;)
}
branches(&apos;v1.6.352&apos;)
}
branches(&apos;v1.6.352&apos;)
}
}

steps {
shell(&apos; export SBT_OPTS=&quot;-Xmx750M -Xms750M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M&quot;; curl -LO https://piccolo.link/sbt-1.1.2.tgz; tar -zxf sbt*.tgz; sbt/bin/sbt compile; &apos;)
if (SCENARIO == &quot;buildmarathon&quot;) {
shell(&apos; export SBT_OPTS=&quot;-Xmx750M -Xms750M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M&quot;; curl -LO https://piccolo.link/sbt-1.1.2.tgz; tar -zxf sbt*.tgz; sbt/bin/sbt compile; &apos;)
} else {
shell(&quot;echo &apos;hello, world&apos;; sleep ${sleepDur}&quot;)
}
}

}
Expand Down
17 changes: 13 additions & 4 deletions tests/scale/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
* 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
* What test scenario to run (--scenario); supported values:
- sleep (sleep for --work-duration)
- buildmarathon (build the open source marathon project)
"""

import logging
Expand Down Expand Up @@ -47,7 +52,8 @@ def test_scaling_load(master_count,
cpu_quota,
work_duration,
mom,
external_volume):
external_volume,
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 @@ -89,7 +95,8 @@ def test_scaling_load(master_count,
single=single_use,
delay=run_delay,
duration=work_duration,
label=m_label)
label=m_label,
scenario=scenario)


@pytest.mark.scalecleanup
Expand Down Expand Up @@ -190,7 +197,8 @@ def _launch_jobs(service_name: str,
single: bool = False,
delay: int = 3,
duration: int = 600,
label: str = None):
label: str = None,
scenario: str = None):
"""Create configured number of jobs with given config on Jenkins
instance identified by `service_name`.
Expand Down Expand Up @@ -226,4 +234,5 @@ def _launch_jobs(service_name: str,
'AGENT_LABEL': label,
'SINGLE_USE': single_use_str,
'EVERY_XMIN': str(delay),
'SLEEP_DURATION': str(duration)})
'SLEEP_DURATION': str(duration),
'SCENARIO': scenario})

0 comments on commit aff99dc

Please sign in to comment.