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

Hello-World MWT & Soak Cluster fixes #2939

Merged
merged 6 commits into from
Feb 22, 2019
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
7 changes: 7 additions & 0 deletions frameworks/helloworld/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def pytest_addoption(parser):
help='Number of hello world services to deploy with a given scenario')
parser.addoption("--scenario", action='store', default='',
help="hello world service yml to use")
parser.addoption("--service-name", action='store', default='hello-world',
help="custom service name to be used instead of default 'hello-world'")


@pytest.fixture
Expand All @@ -24,3 +26,8 @@ def service_count(request) -> int:
@pytest.fixture
def scenario(request) -> str:
return str(request.config.getoption('--scenario'))


@pytest.fixture
def service_name(request) -> str:
return str(request.config.getoption('--service-name'))
33 changes: 29 additions & 4 deletions frameworks/helloworld/tests/scale/test_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,46 @@
log = logging.getLogger(__name__)


@pytest.mark.soak
def test_soak_load(service_name,
scenario) -> None:
"""Launch a soak test scenario. This does not verify the results
of the test, but does ensure the instances were created.

Args:
service_name: name of the service to install as
scenario: yaml scenario to run helloworld with (normal, crashloop) are added for this case
"""
# Note service-names *cannot* have underscores in them.
soak_service_name = ("{}-{}-soak".format(service_name, scenario)).replace("_", "-")
# service-names can have '/'s in them but service account names cannot, sanitize here.
service_account_name = soak_service_name.replace("/", "__")
security_info = _create_service_account(service_account_name)
_install_service(soak_service_name,
scenario,
security_info)


@pytest.mark.scale
def test_scaling_load(service_count,
def test_scaling_load(service_name,
service_count,
scenario) -> None:
"""Launch a load test scenario. This does not verify the results
of the test, but does ensure the instances were created.

Args:
service_name: name of the service to install as
service_count: number of helloworld services to install
scenario: yaml scenario to run helloworld with (normal, crashloop) are added for this case
"""
# TODO: parallelize account creation and installation if time is an issue in scale tests
for index in range(service_count):
service_name = "{}-{}-{}".format(config.PACKAGE_NAME, scenario, index)
security_info = _create_service_account(service_name)
_install_service(service_name,
# Note service-names *cannot* have underscores in them.
scale_service_name = ("{}-{}-{}".format(service_name, scenario, index)).replace("_", "-")
# service-names can have '/'s in them but service account names cannot, sanitize here.
service_account_name = scale_service_name.replace("/", "__")
security_info = _create_service_account(service_account_name)
_install_service(scale_service_name,
scenario,
security_info)

Expand Down
22 changes: 20 additions & 2 deletions testing/sdk_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import sdk_cmd

from distutils.version import LooseVersion
from enum import Enum

log = logging.getLogger(__name__)

Expand All @@ -24,6 +25,11 @@
# Service/task names
###

class DCOS_SECURITY(Enum):
disabled = 1
permissive = 2
strict = 3


def get_package_name(default: str) -> str:
return os.environ.get("INTEGRATION_TEST__PACKAGE_NAME") or default
Expand Down Expand Up @@ -111,7 +117,7 @@ def your_test_here(): ...

In order for this annotation to take effect, this function must be called by a pytest_runtest_setup() hook.
"""
min_version_mark = item.get_marker("dcos_min_version")
min_version_mark = item.get_closest_marker("dcos_min_version")
if min_version_mark:
min_version = min_version_mark.args[0]
message = "Feature only supported in DC/OS {} and up".format(min_version)
Expand All @@ -129,7 +135,19 @@ def is_open_dcos():

def is_strict_mode():
"""Determine if the tests are being run on a strict mode cluster."""
return os.environ.get("SECURITY", "") == "strict"
return get_security_mode() == DCOS_SECURITY.strict


def get_security_mode() -> DCOS_SECURITY:
r = get_metadata().json()
mode = r['security']
return DCOS_SECURITY[mode]


def get_metadata():
return sdk_cmd.cluster_request('GET',
'dcos-metadata/bootstrap-config.json',
retry=False)


"""Annotation which may be used to mark test suites or test cases as EE-only.
Expand Down