path field format } internal disable { integrations } } } } """ % (indent(OPENSHIFT_RESOURCE, 8 * ' '), indent(OPENSHIFT_RESOURCE, 6 * ' ')) QONTRACT_INTEGRATION = 'openshift_resources_base' QONTRACT_INTEGRATION_VERSION = make_semver(1, 9, 2) QONTRACT_BASE64_SUFFIX = '_qb64' APP_INT_BASE_URL = 'https://gitlab.cee.redhat.com/service/app-interface' _log_lock = Lock() class FetchVaultSecretError(Exception): def __init__(self, msg): super().__init__("error fetching vault secret: " + str(msg)) class FetchRouteError(Exception): def __init__(self, msg): super().__init__("error fetching route: " + str(msg))
import traceback import yaml from sretoolbox.utils import threaded from reconcile import queries from reconcile.utils import gql from reconcile.utils import promtool import reconcile.openshift_resources_base as orb from reconcile.utils.semver_helper import make_semver from reconcile.status import ExitCodes from reconcile.utils.structs import CommandExecutionResult QONTRACT_INTEGRATION = "prometheus_rules_tester" QONTRACT_INTEGRATION_VERSION = make_semver(0, 1, 0) PROMETHEUS_RULES_PATHS_QUERY = """ { resources: resources_v1(schema: "/openshift/prometheus-rule-1.yml") { path } } """ PROMETHEUS_RULES_TESTS_QUERY = """ { tests: resources_v1(schema: "/app-interface/prometheus-rule-test-1.yml") { path content }
import pytest from reconcile.utils.semver_helper import make_semver from reconcile.utils.openshift_resource import ( OpenshiftResource as OR, ConstructResourceError, ) from .fixtures import Fixtures fxt = Fixtures("openshift_resource") TEST_INT = "test_openshift_resources" TEST_INT_VER = make_semver(1, 9, 2) class TestOpenshiftResource: @staticmethod def test_verify_valid_k8s_object(): resource = fxt.get_anymarkup("valid_resource.yml") openshift_resource = OR(resource, TEST_INT, TEST_INT_VER) assert openshift_resource.verify_valid_k8s_object() is None @staticmethod def test_verify_valid_k8s_object_false(): resource = fxt.get_anymarkup("invalid_resource.yml") with pytest.raises(ConstructResourceError): openshift_resource = OR(resource, TEST_INT, TEST_INT_VER) assert openshift_resource.verify_valid_k8s_object() is None