Skip to content

Commit

Permalink
Add gitlab_runner e2e (#4356)
Browse files Browse the repository at this point in the history
* Add gitlab_runner e2e

* Fix style
  • Loading branch information
AlexandreYang committed Aug 14, 2019
1 parent d23006b commit e31ebfb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 28 deletions.
2 changes: 1 addition & 1 deletion gitlab_runner/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)


@pytest.fixture(scope="session", autouse=True)
@pytest.fixture(scope="session")
def dd_environment():
"""
Spin up and initialize gitlab_runner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,10 @@

from datadog_checks.gitlab_runner import GitlabRunnerCheck

from .common import ALLOWED_METRICS, BAD_CONFIG, CONFIG, CUSTOM_TAGS, GITLAB_RUNNER_TAGS, HOST


def test_check(aggregator):
"""
Basic Test for gitlab integration.
"""
gitlab_runner = GitlabRunnerCheck('gitlab_runner', CONFIG['init_config'], {}, instances=CONFIG['instances'])

gitlab_runner.check(CONFIG['instances'][0])

aggregator.assert_service_check(
GitlabRunnerCheck.MASTER_SERVICE_CHECK_NAME,
status=GitlabRunnerCheck.OK,
tags=GITLAB_RUNNER_TAGS + CUSTOM_TAGS,
count=1,
)

aggregator.assert_service_check(
GitlabRunnerCheck.PROMETHEUS_SERVICE_CHECK_NAME, status=GitlabRunnerCheck.OK, tags=CUSTOM_TAGS, count=1
)

for metric in ALLOWED_METRICS:
if metric.startswith('ci_runner'):
aggregator.assert_metric("gitlab_runner.{}".format(metric))
else:
aggregator.assert_metric("gitlab_runner.{}".format(metric), tags=CUSTOM_TAGS, count=1)
from .common import BAD_CONFIG, CUSTOM_TAGS, HOST


@pytest.mark.usefixtures("dd_environment")
def test_connection_failure(aggregator):
"""
Make sure we're failing when the URL isn't right
Expand Down
46 changes: 46 additions & 0 deletions gitlab_runner/tests/test_integration_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)

import pytest

from datadog_checks.gitlab_runner import GitlabRunnerCheck

from .common import ALLOWED_METRICS, CONFIG, CUSTOM_TAGS, GITLAB_RUNNER_TAGS


def assert_check(aggregator):
"""
Basic Test for gitlab integration.
"""
aggregator.assert_service_check(
GitlabRunnerCheck.MASTER_SERVICE_CHECK_NAME,
status=GitlabRunnerCheck.OK,
tags=GITLAB_RUNNER_TAGS + CUSTOM_TAGS,
count=2,
)
aggregator.assert_service_check(
GitlabRunnerCheck.PROMETHEUS_SERVICE_CHECK_NAME, status=GitlabRunnerCheck.OK, tags=CUSTOM_TAGS, count=2
)
for metric in ALLOWED_METRICS:
if metric.startswith('ci_runner'):
aggregator.assert_metric("gitlab_runner.{}".format(metric))
else:
aggregator.assert_metric("gitlab_runner.{}".format(metric), tags=CUSTOM_TAGS, count=2)


@pytest.mark.usefixtures("dd_environment")
def test_check(aggregator):
gitlab_runner = GitlabRunnerCheck('gitlab_runner', CONFIG['init_config'], {}, instances=CONFIG['instances'])

gitlab_runner.check(CONFIG['instances'][0])
gitlab_runner.check(CONFIG['instances'][0])

assert_check(aggregator)


@pytest.mark.e2e
def test_e2e(dd_agent_check):
aggregator = dd_agent_check(CONFIG, rate=True)

assert_check(aggregator)
2 changes: 2 additions & 0 deletions gitlab_runner/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ envlist =
py{27,37}-10.8.0

[testenv]
description=
py{27,37}: e2e ready
dd_check_style = true
usedevelop = true
platform = linux|darwin|win32
Expand Down

0 comments on commit e31ebfb

Please sign in to comment.