Skip to content

Commit

Permalink
[WIP] Started adding rexray config. (mesosphere#228)
Browse files Browse the repository at this point in the history
* Started adding rexray config.

* Started Python integration of volumes for scale tests with rexray.

* Fix boolean handling.

* Missed a comma.

* Added mode.

* Missed changing parameters for one function.
  • Loading branch information
jeid64 authored and benclarkwood committed May 10, 2018
1 parent f24ebb6 commit ea0c03a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 12 deletions.
7 changes: 7 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
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 Down Expand Up @@ -33,6 +34,8 @@ def pytest_addoption(parser):
'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.')


@pytest.fixture
Expand Down Expand Up @@ -67,3 +70,7 @@ def work_duration(request) -> int:
@pytest.fixture
def mom(request) -> str:
return request.config.getoption('--mom')

@pytest.fixture
def external_volume(request) -> bool:
return bool(distutils.util.strtobool(request.config.getoption('--external-volume')))
14 changes: 10 additions & 4 deletions testing/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
log = logging.getLogger(__name__)


def install(service_name, role=None, mom=None):
def install(service_name, role=None, mom=None, external_volume=None):
"""Install a Jenkins instance and set the service name to
`service_name`. This does not wait for deployment to finish.
Expand All @@ -25,9 +25,6 @@ def install(service_name, role=None, mom=None):
options = {
"service": {
"name": service_name
},
"storage": {
"persistent-volume-size": 1024
}
}

Expand All @@ -36,6 +33,15 @@ def install(service_name, role=None, mom=None):
"jenkins-agent-role": role
}

if external_volume:
options["storage"] = {
"external-persistent-volume-name": service_name
}
else:
options["storage"] = {
"local-persistent-volume-size": 1024
}

if mom:
# get jenkins marathon app json with desired config.
# this will register at `/service/<service_name>`
Expand Down
10 changes: 6 additions & 4 deletions tests/scale/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def test_scaling_load(master_count,
run_delay,
cpu_quota,
work_duration,
mom):
mom,
external_volume):
"""Launch a load test scenario. This does not verify the results
of the test, but does ensure the instances and jobs were created.
Expand All @@ -62,6 +63,7 @@ def test_scaling_load(master_count,
cpu_quota: CPU quota (0.0 to disable)
work_duration: Time, in seconds, for generated jobs to sleep
mom: Marathon on Marathon instance name
external_volume: External volume on rexray (true) or local volume (false)
"""
with shakedown.marathon_on_marathon(mom):
if cpu_quota is not 0.0:
Expand All @@ -73,7 +75,7 @@ def test_scaling_load(master_count,
install_threads = list()
for service_name in masters:
t = threading.Thread(target=_install_jenkins,
args=(service_name, mom))
args=(service_name, mom, external_volume))
install_threads.append(t)
t.start()
# wait on installation threads
Expand Down Expand Up @@ -139,14 +141,14 @@ def _set_quota(role, cpus):
sdk_quota.create_quota(role, cpus=cpus)


def _install_jenkins(service_name, mom=None):
def _install_jenkins(service_name, mom=None, external_volume=None):
"""Install Jenkins service.
Args:
service_name: Service Name or Marathon ID (same thing)
"""
log.info("Installing jenkins '{}'".format(service_name))
jenkins.install(service_name, role=SHARED_ROLE, mom=mom)
jenkins.install(service_name, role=SHARED_ROLE, mom=mom, external_volume=None)


def _cleanup_jenkins_install(service_name, mom=None):
Expand Down
11 changes: 10 additions & 1 deletion universe/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,23 @@
"description": "The location of a volume on the host to be used for persisting Jenkins configuration and build data. The final location will be derived from this value plus the name set in `name` (e.g. `/mnt/host_volume/jenkins`). Note that this path must be the same on all DC/OS agents.",
"type": "string"
},
"persistent-volume-size": {
"local-persistent-volume-size": {
"description": "Size of the persistent volume. This is applicable only when host-volume is not set",
"type": "number",
"default": 5120
},
"pinned-hostname": {
"description": "An optional DC/OS agent hostname to run this Jenkins instance on (e.g. 10.0.0.1).",
"type" : "string"
},
"external-persistent-volume-name": {
"description": "Name of the persistent volume. This is applicable only when host-volume is not set and local persistent volume is not used",
"type": "string"
},
"external-persistent-volume-size": {
"description": "Size of the external persistent volume. This is applicable only when host-volume is not set",
"type": "number",
"default": 16
}
}
},
Expand Down
18 changes: 15 additions & 3 deletions universe/marathon.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,27 @@
"mode": "RW"
}
{{/storage.host-volume}}
{{^storage.host-volume}}
{{^storage.external-persistent-volume-name}}
{
"persistent": {
"size": {{storage.persistent-volume-size}}
"size": {{storage.local-persistent-volume-size}}
},
"mode": "RW",
"containerPath": "jenkins_home"
}
{{/storage.host-volume}}
{{/storage.external-persistent-volume-name}}
{{#storage.external-persistent-volume-name}}
{
"external": {
"size": {{storage.external-persistent-volume-size}},
"name": "{{storage.external-persistent-volume-name}}",
"provider": "dvdi",
"options": { "dvdi/driver": "rexray" }
},
"mode": "RW",
"containerPath": "jenkins_home"
}
{{/storage.external-persistent-volume-name}}
]
},
{{#advanced.docker-credentials-uri}}
Expand Down

0 comments on commit ea0c03a

Please sign in to comment.