From 02785fd1fc73848164a58f7396b786bba75c7931 Mon Sep 17 00:00:00 2001 From: Sarah Witt Date: Fri, 20 Dec 2024 09:58:52 -0500 Subject: [PATCH] [PLINT-543] Add support for environment metrics and tagging by environment, deployment, and release (#19192) * Add support for environment metrics * Add config for autodiscovery * Add support for environments via discovery * Add environment, release, and deployment tags * Add caching for environments, releases, and deployments * add to caddyfile * remove env fallback * change environments cache to dictionary * use tuple for deployment * Add pagination for environments * update caddyfile * update environments config * sync models * Filter by environment * only collect deploy tasks * update caddyfile --- octopus_deploy/assets/configuration/spec.yaml | 51 + .../datadog_checks/octopus_deploy/check.py | 141 ++- .../octopus_deploy/config_models/instance.py | 12 + .../octopus_deploy/data/conf.yaml.example | 31 + octopus_deploy/metadata.csv | 3 + octopus_deploy/tests/constants.py | 254 +++-- octopus_deploy/tests/docker/Caddyfile | 80 +- .../deployments/Deployments-16/response.json | 71 ++ .../deployments/Deployments-17/response.json | 71 ++ .../deployments/Deployments-18/response.json | 71 ++ .../deployments/Deployments-19/response.json | 71 ++ .../environments/skip=0/take=2/response.json | 50 + .../environments/skip=0/take=30/response.json | 50 + .../releases/Releases-1/response.json | 35 + .../releases/Releases-2/response.json | 35 + .../releases/Releases-3/response.json | 35 + .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 4 +- .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=2/take=2/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 4 +- .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 .../skip=0/take=2/response.json | 0 .../skip=0/take=30/response.json | 0 octopus_deploy/tests/test_unit.py | 989 +++++++++++++++++- 42 files changed, 1876 insertions(+), 182 deletions(-) create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-16/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-17/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-18/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-19/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=2/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=30/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-1/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-2/response.json create mode 100644 octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-3/response.json rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-1/states=Queued,Executing/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-1/states=Queued,Executing/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-2/states=Queued,Executing/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json (96%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=2/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-3/states=Queued,Executing/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json (96%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-4/states=Queued,Executing/skip=0/take=2/response.json (100%) rename octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/{ => name=Deploy}/project=Projects-4/states=Queued,Executing/skip=0/take=30/response.json (100%) diff --git a/octopus_deploy/assets/configuration/spec.yaml b/octopus_deploy/assets/configuration/spec.yaml index 87b5276d4ef24..735c90daacd43 100644 --- a/octopus_deploy/assets/configuration/spec.yaml +++ b/octopus_deploy/assets/configuration/spec.yaml @@ -187,6 +187,57 @@ files: - name: interval type: integer example: {} + - name: environments + display_priority: 6 + description: | + Optional configuration to indicate the environments that we want to be processed. If not configured, + all environments will be processed. + + The 'include' key will indicate the regular expressions of the environments for which metrics are + to be reported. + + The environments will be processed in the order indicated in the 'include'. + If an environment is matched on an 'include' key, it will only be processed there and not in a later 'include' + that it might match on. + + The 'exclude' key will indicate the regular expressions of those environments for which metrics + are not to be reported. + The excludes will have priority over the includes, that is, if an environment matches an exclude, it will not be + processed even if it matches an include. The 'include' key must be used if using the 'exclude' key. + + The 'limit' key will allow limiting the number of environments processed to avoid a combinatorial explosion of + tags associated with a metric. + + The 'interval' key will indicate the validity time of the last list of environments obtained through the + endpoint. If 'interval' is not indicated, the list of environments will be obtained each time the check + is executed and will not be cached. + + In the following example, only the environment named 'prod' will be collected. + + environments: + include: + - 'prod' + + value: + type: object + properties: + - name: limit + description: | + Maximum number of environments to be processed. + type: integer + - name: include + type: array + items: + anyOf: + - type: string + - type: object + - name: exclude + type: array + items: + type: string + - name: interval + type: integer + example: {} - name: paginated_limit description: | Sets the number of items API calls should return at a time. Default is 30. diff --git a/octopus_deploy/datadog_checks/octopus_deploy/check.py b/octopus_deploy/datadog_checks/octopus_deploy/check.py index c71b36875a81a..6d7b7e34cdf5c 100644 --- a/octopus_deploy/datadog_checks/octopus_deploy/check.py +++ b/octopus_deploy/datadog_checks/octopus_deploy/check.py @@ -5,6 +5,7 @@ import datetime from collections.abc import Iterable +from cachetools import TTLCache from requests.exceptions import ConnectionError, HTTPError, InvalidURL, Timeout from datadog_checks.base import AgentCheck @@ -15,6 +16,9 @@ from .config_models import ConfigMixin +TTL_CACHE_MAXSIZE = 50 +TTL_CACHE_TTL = 3600 + EVENT_TO_ALERT_TYPE = { 'MachineHealthy': 'success', 'MachineUnhealthy': 'warning', @@ -41,6 +45,10 @@ def __init__(self, name, init_config, instances): self._project_groups_discovery = {} self._default_projects_discovery = {} self._projects_discovery = {} + self._environments_discovery = {} + self._environments_cache = {} + self._deployments_cache = TTLCache(maxsize=TTL_CACHE_MAXSIZE, ttl=TTL_CACHE_TTL) + self._releases_cache = TTLCache(maxsize=TTL_CACHE_MAXSIZE, ttl=TTL_CACHE_TTL) self._base_tags = self.instance.get("tags", []) self.collect_events = self.instance.get("collect_events", False) @@ -185,6 +193,7 @@ def _process_spaces(self): tags = self._base_tags + [f'space_id:{space_id}', f'space_name:{space_name}'] self.gauge("space.count", 1, tags=tags) self.log.debug("Processing space %s", space_name) + self._process_environments(space_id, space_name) self._process_project_groups( space_id, space_name, space_config.get("project_groups") if space_config else None ) @@ -239,7 +248,7 @@ def _process_projects(self, space_id, space_name, project_group_id, project_grou f"api/{space_id}/projectgroups/{project_group_id}/projects" ).get('Items', []) ] - self.log.debug("Monitoring %s Projects", len(projects)) + self.log.debug("Monitoring %s Projects for %s in %s", len(projects), project_group_name, space_name) for _, _, project, _ in projects: project_id = project.get("Id") project_name = project.get("Name") @@ -253,15 +262,58 @@ def _process_projects(self, space_id, space_name, project_group_id, project_grou self._process_queued_and_running_tasks(space_id, space_name, project_id, project_name) self._process_completed_tasks(space_id, space_name, project_id, project_name) + def _process_environments(self, space_id, space_name): + if self.config.environments: + self._init_environments_discovery(space_id) + environments = list(self._environments_discovery[space_id].get_items()) + else: + environments = [ + (None, environment.get("Name"), environment, None) + for environment in self._process_paginated_endpoint(f"api/{space_id}/environments").get('Items', []) + ] + + self.log.debug("Collecting %s environments for %s", len(environments), space_name) + + for _, _, environment, _ in environments: + environment_name = environment.get("Name") + environment_slug = environment.get("Slug") + environment_id = environment.get("Id") + self._environments_cache[environment_id] = environment_name + use_guided_failure = int(environment.get("UseGuidedFailure", False)) + allow_dynamic_infrastructure = int(environment.get("AllowDynamicInfrastructure", False)) + + tags = self._base_tags + [ + f"space_name:{space_name}", + f"environment_name:{environment_name}", + f"environment_id:{environment_id}", + f"environment_slug:{environment_slug}", + ] + self.gauge("environment.count", 1, tags=tags) + self.gauge("environment.use_guided_failure", use_guided_failure, tags=tags) + self.gauge("environment.allow_dynamic_infrastructure", allow_dynamic_infrastructure, tags=tags) + + def _init_environments_discovery(self, space_id): + self.log.info("Default Environments discovery: %s", self.config.environments) + if space_id not in self._environments_discovery: + self._environments_discovery[space_id] = Discovery( + lambda: self._process_paginated_endpoint(f"api/{space_id}/environments").get('Items', []), + limit=self.config.environments.limit, + include=normalize_discover_config_include(self.config.environments), + exclude=self.config.environments.exclude, + interval=self.config.environments.interval, + key=lambda environment: environment.get("Name"), + ) + def _process_queued_and_running_tasks(self, space_id, space_name, project_id, project_name): self.log.debug("Collecting running and queued tasks for project %s", project_name) - params = {'project': project_id, 'states': ["Queued", "Executing"]} + params = {'name': 'Deploy', 'project': project_id, 'states': ["Queued", "Executing"]} response_json = self._process_paginated_endpoint(f"api/{space_id}/tasks", params) self._process_tasks(space_id, space_name, project_name, response_json.get('Items', [])) def _process_completed_tasks(self, space_id, space_name, project_id, project_name): self.log.debug("Collecting completed tasks for project %s", project_name) params = { + 'name': 'Deploy', 'project': project_id, 'fromCompletedDate': self._from_completed_time, 'toCompletedDate': self._to_completed_time, @@ -303,27 +355,70 @@ def _process_tasks(self, space_id, space_name, project_name, tasks_json): task_name = task.get("Name") server_node = task.get("ServerNode") task_state = task.get("State") - tags = self._base_tags + [ - f'space_name:{space_name}', - f'project_name:{project_name}', - f'task_id:{task_id}', - f'task_name:{task_name}', - f'task_state:{task_state}', - f'server_node:{server_node}', - ] - self.log.debug("Processing task id %s for project %s", task_id, project_name) - queued_time, executing_time, completed_time = self._calculate_task_times(task) - self.gauge("deployment.count", 1, tags=tags) - self.gauge("deployment.queued_time", queued_time, tags=tags) - if executing_time != -1: - self.gauge("deployment.executing_time", executing_time, tags=tags) - - if completed_time != -1: - self.gauge("deployment.completed_time", completed_time, tags=tags) - - if self.logs_enabled: - self.log.debug("Collecting logs for task %s, id: %s", task_name, task_id) - self._collect_deployment_logs(space_id, task_id, tags) + deployment_id = task.get("Arguments", {}).get("DeploymentId") + environment_name, deployment_tags = self._get_deployment_tags(space_id, deployment_id) + if environment_name in self._environments_cache.values(): + tags = ( + self._base_tags + + deployment_tags + + [ + f'space_name:{space_name}', + f'project_name:{project_name}', + f'task_state:{task_state}', + f'server_node:{server_node}', + ] + ) + self.log.debug("Processing task id %s for project %s", task_id, project_name) + queued_time, executing_time, completed_time = self._calculate_task_times(task) + self.gauge("deployment.count", 1, tags=tags) + self.gauge("deployment.queued_time", queued_time, tags=tags) + if executing_time != -1: + self.gauge("deployment.executing_time", executing_time, tags=tags) + + if completed_time != -1: + self.gauge("deployment.completed_time", completed_time, tags=tags) + + if self.logs_enabled: + self.log.debug("Collecting logs for task %s, id: %s", task_name, task_id) + self._collect_deployment_logs(space_id, task_id, tags) + else: + self.log.debug( + "Skipping task id: %s for project %s in skipped environment: %s", + task_id, + project_name, + environment_name, + ) + + def _get_deployment_tags(self, space_id, deployment_id): + self.log.debug("Getting deployment tags for deployment id: %s", deployment_id) + cached_deployment = self._deployments_cache.get(deployment_id) + + if cached_deployment is not None: + release_version = cached_deployment[0] + environment_name = cached_deployment[1] + else: + self.log.debug("Cached deployment not found for deployment id: %s", deployment_id) + deployment = self._process_endpoint(f"api/{space_id}/deployments/{deployment_id}") + release_id = deployment.get("ReleaseId") + environment_id = deployment.get("EnvironmentId") + environment_name = self._environments_cache.get(environment_id) + release_version = self._releases_cache.get(release_id) + if release_version is None: + self.log.debug( + "Cached release not found for deployment id: %s, release id: %s", deployment_id, release_id + ) + release = self._process_endpoint(f"api/{space_id}/releases/{release_id}") + release_version = release.get("Version") + self._releases_cache[release_id] = release_version + + self._deployments_cache[deployment_id] = (release_version, environment_name) + + tags = [ + f'deployment_id:{deployment_id}', + f'release_version:{release_version}', + f'environment_name:{environment_name}', + ] + return environment_name, tags def _collect_server_nodes_metrics(self): self.log.debug("Collecting server node metrics.") diff --git a/octopus_deploy/datadog_checks/octopus_deploy/config_models/instance.py b/octopus_deploy/datadog_checks/octopus_deploy/config_models/instance.py index f94e7f3352c62..4bcf97bd36e47 100644 --- a/octopus_deploy/datadog_checks/octopus_deploy/config_models/instance.py +++ b/octopus_deploy/datadog_checks/octopus_deploy/config_models/instance.py @@ -29,6 +29,17 @@ class AuthToken(BaseModel): writer: Optional[MappingProxyType[str, Any]] = None +class Environments(BaseModel): + model_config = ConfigDict( + arbitrary_types_allowed=True, + frozen=True, + ) + exclude: Optional[tuple[str, ...]] = None + include: Optional[tuple[Union[str, MappingProxyType[str, Any]], ...]] = None + interval: Optional[int] = None + limit: Optional[int] = Field(None, description='Maximum number of environments to be processed.\n') + + class MetricPatterns(BaseModel): model_config = ConfigDict( arbitrary_types_allowed=True, @@ -96,6 +107,7 @@ class InstanceConfig(BaseModel): connect_timeout: Optional[float] = None disable_generic_tags: Optional[bool] = None empty_default_hostname: Optional[bool] = None + environments: Optional[Environments] = None extra_headers: Optional[MappingProxyType[str, Any]] = None headers: Optional[MappingProxyType[str, Any]] = None kerberos_auth: Optional[str] = None diff --git a/octopus_deploy/datadog_checks/octopus_deploy/data/conf.yaml.example b/octopus_deploy/datadog_checks/octopus_deploy/data/conf.yaml.example index 06ed18e138363..e21039761e8b6 100644 --- a/octopus_deploy/datadog_checks/octopus_deploy/data/conf.yaml.example +++ b/octopus_deploy/datadog_checks/octopus_deploy/data/conf.yaml.example @@ -51,6 +51,37 @@ instances: # - octopus_endpoint: http://localhost:80/api + ## @param environments - mapping - optional + ## Optional configuration to indicate the environments that we want to be processed. If not configured, + ## all environments will be processed. + ## + ## The 'include' key will indicate the regular expressions of the environments for which metrics are + ## to be reported. + ## + ## The environments will be processed in the order indicated in the 'include'. + ## If an environment is matched on an 'include' key, it will only be processed there and not in a later 'include' + ## that it might match on. + ## + ## The 'exclude' key will indicate the regular expressions of those environments for which metrics + ## are not to be reported. + ## The excludes will have priority over the includes, that is, if an environment matches an exclude, it will not be + ## processed even if it matches an include. The 'include' key must be used if using the 'exclude' key. + ## + ## The 'limit' key will allow limiting the number of environments processed to avoid a combinatorial explosion of + ## tags associated with a metric. + ## + ## The 'interval' key will indicate the validity time of the last list of environments obtained through the + ## endpoint. If 'interval' is not indicated, the list of environments will be obtained each time the check + ## is executed and will not be cached. + ## + ## In the following example, only the environment named 'prod' will be collected. + ## + ## environments: + ## include: + ## - 'prod' + # + # environments: {} + ## @param headers - mapping - optional ## Headers to use for every request. An Authorization header including the Octopus Deploy API key token is required ## for authentication for the REST API. diff --git a/octopus_deploy/metadata.csv b/octopus_deploy/metadata.csv index a41002aa00758..5f23c711b8217 100644 --- a/octopus_deploy/metadata.csv +++ b/octopus_deploy/metadata.csv @@ -4,6 +4,9 @@ octopus_deploy.deployment.completed_time,gauge,,second,,Duration of deployment., octopus_deploy.deployment.count,gauge,,,,Number of deployments monitored.,-1,octopus_deploy,octopus_deploy deploy count,, octopus_deploy.deployment.executing_time,gauge,,second,,How long the deployment has been executing.,-1,octopus_deploy,octopus_deploy deploy dur,, octopus_deploy.deployment.queued_time,gauge,,second,,Time deployment was in queue.,-1,octopus_deploy,octopus_deploy deploy queue,, +octopus_deploy.environment.allow_dynamic_infrastructure,gauge,,,,Whether or not the environment allows dynamic infrastructure.,-1,octopus_deploy,octopus_deploy env infra,, +octopus_deploy.environment.count,gauge,,,,Number of environments discovered.,-1,octopus_deploy,octopus_deploy env count,, +octopus_deploy.environment.use_guided_failure,gauge,,,,Whether or not the environment is in guided failure mode.,-1,octopus_deploy,octopus_deploy env guided failure,, octopus_deploy.project.count,gauge,,,,Number of projects discovered.,-1,octopus_deploy,octopus_deploy projects count,, octopus_deploy.project_group.count,gauge,,,,Number of project groups discovered.,-1,octopus_deploy,octopus_deploy project group count,, octopus_deploy.server_node.count,gauge,,,,Number of Octopus server nodes discovered.,-1,octopus_deploy,octopus_deploy server count,, diff --git a/octopus_deploy/tests/constants.py b/octopus_deploy/tests/constants.py index 2dce9ef9aa1f7..b7300359739c9 100644 --- a/octopus_deploy/tests/constants.py +++ b/octopus_deploy/tests/constants.py @@ -33,30 +33,36 @@ "octopus_deploy.server_node.count", "octopus_deploy.server_node.in_maintenance_mode", "octopus_deploy.server_node.max_concurrent_tasks", + "octopus_deploy.environment.allow_dynamic_infrastructure", + "octopus_deploy.environment.count", + "octopus_deploy.environment.use_guided_failure", ] ALL_METRICS = ["octopus_deploy.deployment.completed_time"] + E2E_METRICS ALL_DEPLOYMENT_LOGS = [ { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The deployment failed because one or more steps failed. Please see the deployment log for details.', 'timestamp': 1727104203218, 'status': 'Fatal', 'stage_name': 'Deploy test release 0.0.2 to Development', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'hello', 'timestamp': 1727104198525, 'status': 'Info', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': "The step failed: Activity Run a Script on the Octopus Server failed with error " "'The remote script failed with exit code 1'.", 'timestamp': 1727104202767, @@ -64,8 +70,9 @@ 'stage_name': 'Step 2: Run a Script', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'ParserError: At /home/octopus/.octopus/OctopusServer/Server/Work/' '09234928998123-1847-68/Script.ps1:1 char:6', 'timestamp': 1727104202599, @@ -73,162 +80,182 @@ 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ echo "stop', 'timestamp': 1727104202599, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ ~~~~~', 'timestamp': 1727104202599, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The string is missing the terminator: ".', 'timestamp': 1727104202599, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'At /home/octopus/.octopus/OctopusServer/Server/Work/09234928998123-1847-68/Script.ps1:1 char:6', 'timestamp': 1727104202605, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ echo "stop', 'timestamp': 1727104202605, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ ~~~~~', 'timestamp': 1727104202605, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'at , : line 1', 'timestamp': 1727104202606, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', - 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/09234928998123-1847-68/' - 'Octopus.FunctionAppenderContext.ps1: line 258', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/' + '09234928998123-1847-68/Octopus.FunctionAppenderContext.ps1: line 258', 'timestamp': 1727104202606, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', - 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/09234928998123-1847-68/' - 'Bootstrap.Octopus.FunctionAppenderContext.ps1: line 1505', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/' + '09234928998123-1847-68/Bootstrap.Octopus.FunctionAppenderContext.ps1: line 1505', 'timestamp': 1727104202607, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'at , : line 1', 'timestamp': 1727104202607, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'at , : line 1', 'timestamp': 1727104202607, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The remote script failed with exit code 1', 'timestamp': 1727104202733, 'status': 'Fatal', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The action Run a Script on the Octopus Server failed', 'timestamp': 1727104202758, 'status': 'Fatal', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1846,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-18,release_version:0.0.1,environment_name:staging,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The deployment completed successfully.', 'timestamp': 1727103628255, 'status': 'Info', 'stage_name': 'Deploy test release 0.0.1 to Staging', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1846,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-18,release_version:0.0.1,environment_name:staging,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'hello', 'timestamp': 1727103627639, 'status': 'Info', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1845,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-17,release_version:0.0.1,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The deployment completed successfully.', 'timestamp': 1727103621669, 'status': 'Info', 'stage_name': 'Deploy test release 0.0.1 to Development', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1845,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-17,release_version:0.0.1,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'hello', 'timestamp': 1727103621208, 'status': 'Info', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test-api,task_id:ServerTasks-1844,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-16,release_version:0.1.5,environment_name:dev,' + 'space_name:Default,project_name:test-api,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The deployment completed successfully.', 'timestamp': 1727103442532, 'status': 'Info', 'stage_name': 'Deploy test-api release 0.1.5 to Development', }, { - 'ddtags': 'space_name:Default,project_name:test-api,task_id:ServerTasks-1844,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-16,release_version:0.1.5,environment_name:dev,' + 'space_name:Default,project_name:test-api,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'Testing', 'timestamp': 1727103440967, 'status': 'Info', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test-api,task_id:ServerTasks-1844,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-16,release_version:0.1.5,environment_name:dev,' + 'space_name:Default,project_name:test-api,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'test', 'timestamp': 1727103442029, 'status': 'Info', @@ -238,172 +265,193 @@ ONLY_TEST_LOGS = [ { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The deployment failed because one or more steps failed. Please see the deployment log for details.', 'timestamp': 1727104203218, 'status': 'Fatal', 'stage_name': 'Deploy test release 0.0.2 to Development', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'hello', 'timestamp': 1727104198525, 'status': 'Info', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', - 'message': "The step failed: Activity Run a Script on the Octopus Server failed with error " - "'The remote script failed with exit code 1'.", + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'message': "The step failed: Activity Run a Script on the Octopus Server failed with error" + " 'The remote script failed with exit code 1'.", 'timestamp': 1727104202767, 'status': 'Fatal', 'stage_name': 'Step 2: Run a Script', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', - 'message': 'ParserError: At /home/octopus/.octopus/OctopusServer/Server/Work/09234928998123-1847-68/' - 'Script.ps1:1 char:6', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'message': 'ParserError: At /home/octopus/.octopus/OctopusServer/Server/Work/' + '09234928998123-1847-68/Script.ps1:1 char:6', 'timestamp': 1727104202599, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ echo "stop', 'timestamp': 1727104202599, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ ~~~~~', 'timestamp': 1727104202599, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The string is missing the terminator: ".', 'timestamp': 1727104202599, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', - 'message': 'At /home/octopus/.octopus/OctopusServer/Server/Work/09234928998123-1847-68/Script.ps1:1 char:6', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'message': 'At /home/octopus/.octopus/OctopusServer/Server/Work/' '09234928998123-1847-68/Script.ps1:1 char:6', 'timestamp': 1727104202605, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ echo "stop', 'timestamp': 1727104202605, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': '+ ~~~~~', 'timestamp': 1727104202605, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'at , : line 1', 'timestamp': 1727104202606, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', - 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/09234928998123-1847-68/' - 'Octopus.FunctionAppenderContext.ps1: line 258', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/' + '09234928998123-1847-68/Octopus.FunctionAppenderContext.ps1: line 258', 'timestamp': 1727104202606, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', - 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/09234928998123-1847-68/' - 'Bootstrap.Octopus.FunctionAppenderContext.ps1: line 1505', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'message': 'at , /home/octopus/.octopus/OctopusServer/Server/Work/' + '09234928998123-1847-68/Bootstrap.Octopus.FunctionAppenderContext.ps1: line 1505', 'timestamp': 1727104202607, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'at , : line 1', 'timestamp': 1727104202607, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'at , : line 1', 'timestamp': 1727104202607, 'status': 'Error', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The remote script failed with exit code 1', 'timestamp': 1727104202733, 'status': 'Fatal', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1847,' - 'task_name:Deploy,task_state:Failed,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-19,release_version:0.0.2,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Failed,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The action Run a Script on the Octopus Server failed', 'timestamp': 1727104202758, 'status': 'Fatal', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1846,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-18,release_version:0.0.1,environment_name:staging,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The deployment completed successfully.', 'timestamp': 1727103628255, 'status': 'Info', 'stage_name': 'Deploy test release 0.0.1 to Staging', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1846,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-18,release_version:0.0.1,environment_name:staging,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'hello', 'timestamp': 1727103627639, 'status': 'Info', 'stage_name': 'Octopus Server', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1845,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-17,release_version:0.0.1,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'The deployment completed successfully.', 'timestamp': 1727103621669, 'status': 'Info', 'stage_name': 'Deploy test release 0.0.1 to Development', }, { - 'ddtags': 'space_name:Default,project_name:test,task_id:ServerTasks-1845,' - 'task_name:Deploy,task_state:Success,server_node:OctopusServerNodes-50c3dfbarc82', + 'ddtags': 'deployment_id:Deployments-17,release_version:0.0.1,environment_name:dev,' + 'space_name:Default,project_name:test,task_state:Success,' + 'server_node:OctopusServerNodes-50c3dfbarc82', 'message': 'hello', 'timestamp': 1727103621208, 'status': 'Info', diff --git a/octopus_deploy/tests/docker/Caddyfile b/octopus_deploy/tests/docker/Caddyfile index b78c45e8b0422..56cd119a49a1f 100644 --- a/octopus_deploy/tests/docker/Caddyfile +++ b/octopus_deploy/tests/docker/Caddyfile @@ -50,7 +50,7 @@ expression {query.project}.contains("Projects-1") && {query.states}.contains("Queued") && {query.states}.contains("Executing") } route @get_running_tasks_project_1 { - rewrite * /GET/api/Spaces-1/tasks/project=Projects-1/states=Queued,Executing/skip=0/take=30/response.json + rewrite * /GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/states=Queued,Executing/skip=0/take=30/response.json file_server } @get_running_tasks_project_2 { @@ -59,7 +59,7 @@ expression {query.project}.contains("Projects-2") && {query.states}.contains("Queued") && {query.states}.contains("Executing") } route @get_running_tasks_project_2 { - rewrite * /GET/api/Spaces-1/tasks/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json + rewrite * /GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json file_server } @get_running_tasks_project_3 { @@ -68,7 +68,7 @@ expression {query.project}.contains("Projects-3") && {query.states}.contains("Queued") && {query.states}.contains("Executing") } route @get_running_tasks_project_3 { - rewrite * /GET/api/Spaces-1/tasks/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json + rewrite * /GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json file_server } @get_running_tasks_project_4 { @@ -77,7 +77,7 @@ expression {query.project}.contains("Projects-4") && {query.states}.contains("Queued") && {query.states}.contains("Executing") } route @get_running_tasks_project_4 { - rewrite * /GET/api/Spaces-1/tasks/project=Projects-4/states=Queued,Executing/skip=0/take=30/response.json + rewrite * /GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/states=Queued,Executing/skip=0/take=30/response.json file_server } @get_completed_tasks_project_1 { @@ -86,7 +86,7 @@ expression {query.project}.contains("Projects-1") && {query}.contains("fromCompletedDate") && {query}.contains("toCompletedDate") } route @get_completed_tasks_project_1 { - rewrite * "/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" + rewrite * "/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" file_server } @get_completed_tasks_project_2 { @@ -95,7 +95,7 @@ expression {query.project}.contains("Projects-2") && {query}.contains("fromCompletedDate") && {query}.contains("toCompletedDate") } route @get_completed_tasks_project_2 { - rewrite * "/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" + rewrite * "/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" file_server } @get_completed_tasks_project_3 { @@ -104,7 +104,7 @@ expression {query.project}.contains("Projects-3") && {query}.contains("fromCompletedDate") && {query}.contains("toCompletedDate") } route @get_completed_tasks_project_3 { - rewrite * "/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" + rewrite * "/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" file_server } @get_completed_tasks_project_4 { @@ -113,7 +113,7 @@ expression {query.project}.contains("Projects-4") && {query}.contains("fromCompletedDate") && {query}.contains("toCompletedDate") } route @get_completed_tasks_project_4 { - rewrite * "/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" + rewrite * "/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json" file_server } @get_octopusservernodes { @@ -156,6 +156,70 @@ rewrite * /GET/api/Spaces-1/tasks/ServerTasks-1847/details/response.json file_server } + @get_environments { + method GET + path /api/Spaces-1/environments + } + route @get_environments { + rewrite * /GET/api/Spaces-1/environments/skip=0/take=30/response.json + file_server + } + @get_releases_1 { + method GET + path /api/Spaces-1/releases/Releases-1 + } + route @get_releases_1 { + rewrite * /GET/api/Spaces-1/releases/Releases-1/response.json + file_server + } + @get_releases_2 { + method GET + path /api/Spaces-1/releases/Releases-2 + } + route @get_releases_2 { + rewrite * /GET/api/Spaces-1/releases/Releases-2/response.json + file_server + } + @get_releases_3 { + method GET + path /api/Spaces-1/releases/Releases-3 + } + route @get_releases_3 { + rewrite * /GET/api/Spaces-1/releases/Releases-3/response.json + file_server + } + @get_deployments_16 { + method GET + path /api/Spaces-1/deployments/Deployments-16 + } + route @get_deployments_16 { + rewrite * /GET/api/Spaces-1/deployments/Deployments-16/response.json + file_server + } + @get_deployments_17 { + method GET + path /api/Spaces-1/deployments/Deployments-17 + } + route @get_deployments_17 { + rewrite * /GET/api/Spaces-1/deployments/Deployments-17/response.json + file_server + } + @get_deployments_18 { + method GET + path /api/Spaces-1/deployments/Deployments-18 + } + route @get_deployments_18 { + rewrite * /GET/api/Spaces-1/deployments/Deployments-18/response.json + file_server + } + @get_deployments_19 { + method GET + path /api/Spaces-1/deployments/Deployments-19 + } + route @get_deployments_19 { + rewrite * /GET/api/Spaces-1/deployments/Deployments-19/response.json + file_server + } file_server browse } diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-16/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-16/response.json new file mode 100644 index 0000000000000..eed9401b22176 --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-16/response.json @@ -0,0 +1,71 @@ +{ + "Id": "Deployments-16", + "SpaceId": "Spaces-1", + "ReleaseId": "Releases-2", + "ChannelId": "Channels-1", + "DeploymentProcessId": "deploymentprocess-Projects-1-s-1-MNSER", + "Changes": [ + { + "Version": "0.1.4", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + }, + { + "Version": "0.1.5", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + } + ], + "ChangesMarkdown": "\n**Release 0.1.4**\n\n\n\n\n**Release 0.1.5**\n\n\n\n", + "EnvironmentId": "Environments-1", + "TenantId": null, + "ForcePackageDownload": false, + "ForcePackageRedeployment": false, + "Priority": "LifecycleDefault", + "SkipActions": [], + "SpecificMachineIds": [], + "ExcludedMachineIds": [], + "ManifestVariableSetId": null, + "TaskId": "ServerTasks-1844", + "ProjectId": "Projects-1", + "UseGuidedFailure": false, + "Comments": null, + "FormValues": {}, + "QueueTime": null, + "QueueTimeExpiry": null, + "Name": "Deploy to dev", + "Created": "2024-09-2T14:42:40.224+00:00", + "TentacleRetentionPeriod": { + "Unit": "Days", + "QuantityToKeep": 0, + "ShouldKeepForever": true + }, + "ChangeRequestSettings": null, + "DeployedBy": "test", + "DeployedById": "Users-1", + "FailureEncountered": false, + "DeployedToMachineIds": [], + "ExecutionPlanLogContext": { + "Steps": [ + { + "Slug": "run-a-script", + "CorrelationId": "ServerTasks-1844" + } + ] + }, + "Links": { + "Self": "/api/Spaces-1/deployments/Deployments-1", + "Release": "/api/Spaces-1/releases/Releases-2", + "Environment": "/api/Spaces-1/environments/Environments-1", + "Project": "/api/Spaces-1/projects/Projects-1", + "Task": "/api/tasks/ServerTasks-1844", + "Web": "/app#/Spaces-1/deployments/Deployments-1", + "Artifacts": "/api/Spaces-1/artifacts?regarding=Deployments-1", + "Interruptions": "/api/Spaces-1/interruptions?regarding=Deployments-1", + "DeploymentProcess": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-1-s-1-KSJDF" + } + } \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-17/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-17/response.json new file mode 100644 index 0000000000000..3c938161a3ae0 --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-17/response.json @@ -0,0 +1,71 @@ +{ + "Id": "Deployments-17", + "SpaceId": "Spaces-1", + "ReleaseId": "Releases-1", + "ChannelId": "Channels-1", + "DeploymentProcessId": "deploymentprocess-Projects-1-s-1-MNSER", + "Changes": [ + { + "Version": "0.0.1", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + }, + { + "Version": "0.0.1", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + } + ], + "ChangesMarkdown": "\n**Release 0.0.1**\n\n\n\n\n**Release 0.0.1**\n\n\n\n", + "EnvironmentId": "Environments-1", + "TenantId": null, + "ForcePackageDownload": false, + "ForcePackageRedeployment": false, + "Priority": "LifecycleDefault", + "SkipActions": [], + "SpecificMachineIds": [], + "ExcludedMachineIds": [], + "ManifestVariableSetId": null, + "TaskId": "ServerTasks-1845", + "ProjectId": "Projects-1", + "UseGuidedFailure": false, + "Comments": null, + "FormValues": {}, + "QueueTime": null, + "QueueTimeExpiry": null, + "Name": "Deploy to dev", + "Created": "2024-09-2T14:42:40.224+00:00", + "TentacleRetentionPeriod": { + "Unit": "Days", + "QuantityToKeep": 0, + "ShouldKeepForever": true + }, + "ChangeRequestSettings": null, + "DeployedBy": "test", + "DeployedById": "Users-1", + "FailureEncountered": false, + "DeployedToMachineIds": [], + "ExecutionPlanLogContext": { + "Steps": [ + { + "Slug": "run-a-script", + "CorrelationId": "ServerTasks-1845" + } + ] + }, + "Links": { + "Self": "/api/Spaces-1/deployments/Deployments-1", + "Release": "/api/Spaces-1/releases/Releases-2", + "Environment": "/api/Spaces-1/environments/Environments-1", + "Project": "/api/Spaces-1/projects/Projects-1", + "Task": "/api/tasks/ServerTasks-1845", + "Web": "/app#/Spaces-1/deployments/Deployments-1", + "Artifacts": "/api/Spaces-1/artifacts?regarding=Deployments-1", + "Interruptions": "/api/Spaces-1/interruptions?regarding=Deployments-1", + "DeploymentProcess": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-1-s-1-KSJDF" + } + } \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-18/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-18/response.json new file mode 100644 index 0000000000000..dd4d5beb69939 --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-18/response.json @@ -0,0 +1,71 @@ +{ + "Id": "Deployments-18", + "SpaceId": "Spaces-1", + "ReleaseId": "Releases-1", + "ChannelId": "Channels-1", + "DeploymentProcessId": "deploymentprocess-Projects-1-s-1-MNSER", + "Changes": [ + { + "Version": "0.0.1", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + }, + { + "Version": "0.0.1", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + } + ], + "ChangesMarkdown": "\n**Release 0.0.1**\n\n\n\n\n**Release 0.0.1**\n\n\n\n", + "EnvironmentId": "Environments-2", + "TenantId": null, + "ForcePackageDownload": false, + "ForcePackageRedeployment": false, + "Priority": "LifecycleDefault", + "SkipActions": [], + "SpecificMachineIds": [], + "ExcludedMachineIds": [], + "ManifestVariableSetId": null, + "TaskId": "ServerTasks-1845", + "ProjectId": "Projects-1", + "UseGuidedFailure": false, + "Comments": null, + "FormValues": {}, + "QueueTime": null, + "QueueTimeExpiry": null, + "Name": "Deploy to staging", + "Created": "2024-09-2T14:42:40.224+00:00", + "TentacleRetentionPeriod": { + "Unit": "Days", + "QuantityToKeep": 0, + "ShouldKeepForever": true + }, + "ChangeRequestSettings": null, + "DeployedBy": "test", + "DeployedById": "Users-1", + "FailureEncountered": false, + "DeployedToMachineIds": [], + "ExecutionPlanLogContext": { + "Steps": [ + { + "Slug": "run-a-script", + "CorrelationId": "ServerTasks-1845" + } + ] + }, + "Links": { + "Self": "/api/Spaces-1/deployments/Deployments-1", + "Release": "/api/Spaces-1/releases/Releases-2", + "Environment": "/api/Spaces-1/environments/Environments-1", + "Project": "/api/Spaces-1/projects/Projects-1", + "Task": "/api/tasks/ServerTasks-1845", + "Web": "/app#/Spaces-1/deployments/Deployments-1", + "Artifacts": "/api/Spaces-1/artifacts?regarding=Deployments-1", + "Interruptions": "/api/Spaces-1/interruptions?regarding=Deployments-1", + "DeploymentProcess": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-1-s-1-KSJDF" + } + } \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-19/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-19/response.json new file mode 100644 index 0000000000000..4050f259abb73 --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/deployments/Deployments-19/response.json @@ -0,0 +1,71 @@ +{ + "Id": "Deployments-19", + "SpaceId": "Spaces-1", + "ReleaseId": "Releases-3", + "ChannelId": "Channels-1", + "DeploymentProcessId": "deploymentprocess-Projects-1-s-1-MNSER", + "Changes": [ + { + "Version": "0.0.2", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + }, + { + "Version": "0.0.2", + "ReleaseNotes": null, + "BuildInformation": [], + "WorkItems": [], + "Commits": [] + } + ], + "ChangesMarkdown": "\n**Release 0.0.2**\n\n\n\n\n**Release 0.0.2**\n\n\n\n", + "EnvironmentId": "Environments-1", + "TenantId": null, + "ForcePackageDownload": false, + "ForcePackageRedeployment": false, + "Priority": "LifecycleDefault", + "SkipActions": [], + "SpecificMachineIds": [], + "ExcludedMachineIds": [], + "ManifestVariableSetId": null, + "TaskId": "ServerTasks-1847", + "ProjectId": "Projects-1", + "UseGuidedFailure": false, + "Comments": null, + "FormValues": {}, + "QueueTime": null, + "QueueTimeExpiry": null, + "Name": "Deploy to staging", + "Created": "2024-09-2T14:42:40.224+00:00", + "TentacleRetentionPeriod": { + "Unit": "Days", + "QuantityToKeep": 0, + "ShouldKeepForever": true + }, + "ChangeRequestSettings": null, + "DeployedBy": "test", + "DeployedById": "Users-1", + "FailureEncountered": false, + "DeployedToMachineIds": [], + "ExecutionPlanLogContext": { + "Steps": [ + { + "Slug": "run-a-script", + "CorrelationId": "ServerTasks-1847" + } + ] + }, + "Links": { + "Self": "/api/Spaces-1/deployments/Deployments-1", + "Release": "/api/Spaces-1/releases/Releases-2", + "Environment": "/api/Spaces-1/environments/Environments-1", + "Project": "/api/Spaces-1/projects/Projects-1", + "Task": "/api/tasks/ServerTasks-1847", + "Web": "/app#/Spaces-1/deployments/Deployments-1", + "Artifacts": "/api/Spaces-1/artifacts?regarding=Deployments-1", + "Interruptions": "/api/Spaces-1/interruptions?regarding=Deployments-1", + "DeploymentProcess": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-1-s-1-KSJDF" + } + } diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=2/response.json new file mode 100644 index 0000000000000..138653ed69549 --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=2/response.json @@ -0,0 +1,50 @@ +{ + "ItemType": "Environment", + "TotalResults": 2, + "ItemsPerPage": 2, + "NumberOfPages": 1, + "LastPageNumber": 0, + "Items": [ + { + "Id": "Environments-1", + "SpaceId": "Spaces-1", + "Slug": "dev", + "Name": "dev", + "Description": "", + "SortOrder": 0, + "UseGuidedFailure": false, + "AllowDynamicInfrastructure": true, + "ExtensionSettings": [], + "Links": { + "Self": "/api/Spaces-1/environments/Environments-1", + "Machines": "/api/Spaces-1/environments/Environments-1/machines{?skip,take,partialName,roles,isDisabled,healthStatuses,commStyles,tenantIds,tenantTags,shellNames,deploymentTargetTypes}", + "SinglyScopedVariableDetails": "/api/Spaces-1/environments/Environments-1/singlyScopedVariableDetails", + "Metadata": "/api/Spaces-1/environments/Environments-1/metadata" + } + }, + { + "Id": "Environments-2", + "SpaceId": "Spaces-1", + "Slug": "staging", + "Name": "staging", + "Description": "", + "SortOrder": 1, + "UseGuidedFailure": false, + "AllowDynamicInfrastructure": false, + "ExtensionSettings": [], + "Links": { + "Self": "/api/Spaces-1/environments/Environments-21", + "Machines": "/api/Spaces-1/environments/Environments-21/machines{?skip,take,partialName,roles,isDisabled,healthStatuses,commStyles,tenantIds,tenantTags,shellNames,deploymentTargetTypes}", + "SinglyScopedVariableDetails": "/api/Spaces-1/environments/Environments-21/singlyScopedVariableDetails", + "Metadata": "/api/Spaces-1/environments/Environments-21/metadata" + } + } + ], + "Links": { + "Self": "/api/Spaces-1/environments?skip=0&take=10", + "Template": "/api/Spaces-1/environments{?skip,ids,take,partialName}", + "Page.All": "/api/Spaces-1/environments?skip=0&take=2147483647", + "Page.Current": "/api/Spaces-1/environments?skip=0&take=10", + "Page.Last": "/api/Spaces-1/environments?skip=0&take=10" + } +} \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=30/response.json new file mode 100644 index 0000000000000..f04f2adc3199d --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/environments/skip=0/take=30/response.json @@ -0,0 +1,50 @@ +{ + "ItemType": "Environment", + "TotalResults": 2, + "ItemsPerPage": 30, + "NumberOfPages": 1, + "LastPageNumber": 0, + "Items": [ + { + "Id": "Environments-1", + "SpaceId": "Spaces-1", + "Slug": "dev", + "Name": "dev", + "Description": "", + "SortOrder": 0, + "UseGuidedFailure": false, + "AllowDynamicInfrastructure": true, + "ExtensionSettings": [], + "Links": { + "Self": "/api/Spaces-1/environments/Environments-1", + "Machines": "/api/Spaces-1/environments/Environments-1/machines{?skip,take,partialName,roles,isDisabled,healthStatuses,commStyles,tenantIds,tenantTags,shellNames,deploymentTargetTypes}", + "SinglyScopedVariableDetails": "/api/Spaces-1/environments/Environments-1/singlyScopedVariableDetails", + "Metadata": "/api/Spaces-1/environments/Environments-1/metadata" + } + }, + { + "Id": "Environments-2", + "SpaceId": "Spaces-1", + "Slug": "staging", + "Name": "staging", + "Description": "", + "SortOrder": 1, + "UseGuidedFailure": false, + "AllowDynamicInfrastructure": false, + "ExtensionSettings": [], + "Links": { + "Self": "/api/Spaces-1/environments/Environments-21", + "Machines": "/api/Spaces-1/environments/Environments-21/machines{?skip,take,partialName,roles,isDisabled,healthStatuses,commStyles,tenantIds,tenantTags,shellNames,deploymentTargetTypes}", + "SinglyScopedVariableDetails": "/api/Spaces-1/environments/Environments-21/singlyScopedVariableDetails", + "Metadata": "/api/Spaces-1/environments/Environments-21/metadata" + } + } + ], + "Links": { + "Self": "/api/Spaces-1/environments?skip=0&take=10", + "Template": "/api/Spaces-1/environments{?skip,ids,take,partialName}", + "Page.All": "/api/Spaces-1/environments?skip=0&take=2147483647", + "Page.Current": "/api/Spaces-1/environments?skip=0&take=10", + "Page.Last": "/api/Spaces-1/environments?skip=0&take=10" + } +} \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-1/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-1/response.json new file mode 100644 index 0000000000000..cff71b09dec51 --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-1/response.json @@ -0,0 +1,35 @@ +{ + "Id": "Releases-1", + "SpaceId": "Spaces-1", + "ProjectId": "Projects-1", + "Version": "0.0.1", + "ChannelId": "Channels-1", + "ReleaseNotes": null, + "ProjectDeploymentProcessSnapshotId": "deploymentprocess-Projects-1-s-1", + "IgnoreChannelRules": false, + "BuildInformation": [], + "Assembled": "2024-09-25T14:19:41.123+00:00", + "LibraryVariableSetSnapshotIds": [], + "SelectedPackages": [], + "SelectedGitResources": [], + "ProjectVariableSetSnapshotId": "variableset-Projects-1-s-0", + "VersionControlReference": null, + "Links": { + "Self": "/api/Spaces-1/releases/Releases-1", + "Project": "/api/Spaces-1/projects/Projects-1", + "Channel": "/api/Spaces-1/projects/Projects-1/channels/Channels-1", + "Progression": "/api/Spaces-1/releases/Releases-1/progression", + "Deployments": "/api/Spaces-1/releases/Releases-1/deployments{?skip,take}", + "DeploymentTemplate": "/api/Spaces-1/releases/Releases-1/deployments/template", + "Artifacts": "/api/Spaces-1/artifacts?regarding=Releases-1", + "ProjectVariableSnapshot": "/api/Spaces-1/variables/variableset-Projects-1-s-0", + "ProjectDeploymentProcessSnapshot": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-1-s-1", + "Web": "/app#/Spaces-1/releases/Releases-1", + "SnapshotVariables": "/api/Spaces-1/releases/Releases-1/snapshot-variables", + "Defects": "/api/Spaces-1/releases/Releases-1/defects", + "ReportDefect": "/api/Spaces-1/releases/Releases-1/defects", + "ResolveDefect": "/api/Spaces-1/releases/Releases-1/defects/resolve", + "DeploymentPreviews": "/api/Spaces-1/releases/Releases-1/deployments/previews/", + "Variables": "/api/Spaces-1/projects/Projects-1/releases/Releases-1/variables" + } + } \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-2/response.json new file mode 100644 index 0000000000000..a34c9b531a08b --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-2/response.json @@ -0,0 +1,35 @@ +{ + "Id": "Releases-2", + "SpaceId": "Spaces-1", + "ProjectId": "Projects-1", + "Version": "0.1.5", + "ChannelId": "Channels-1", + "ReleaseNotes": null, + "ProjectDeploymentProcessSnapshotId": "deploymentprocess-Projects-1-s-1", + "IgnoreChannelRules": false, + "BuildInformation": [], + "Assembled": "2024-09-25T14:19:41.123+00:00", + "LibraryVariableSetSnapshotIds": [], + "SelectedPackages": [], + "SelectedGitResources": [], + "ProjectVariableSetSnapshotId": "variableset-Projects-1-s-0", + "VersionControlReference": null, + "Links": { + "Self": "/api/Spaces-1/releases/Releases-2", + "Project": "/api/Spaces-1/projects/Projects-1", + "Channel": "/api/Spaces-1/projects/Projects-1/channels/Channels-1", + "Progression": "/api/Spaces-1/releases/Releases-2/progression", + "Deployments": "/api/Spaces-1/releases/Releases-2/deployments{?skip,take}", + "DeploymentTemplate": "/api/Spaces-1/releases/Releases-2/deployments/template", + "Artifacts": "/api/Spaces-1/artifacts?regarding=Releases-2", + "ProjectVariableSnapshot": "/api/Spaces-1/variables/variableset-Projects-1-s-0", + "ProjectDeploymentProcessSnapshot": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-1-s-1", + "Web": "/app#/Spaces-1/releases/Releases-2", + "SnapshotVariables": "/api/Spaces-1/releases/Releases-2/snapshot-variables", + "Defects": "/api/Spaces-1/releases/Releases-2/defects", + "ReportDefect": "/api/Spaces-1/releases/Releases-2/defects", + "ResolveDefect": "/api/Spaces-1/releases/Releases-2/defects/resolve", + "DeploymentPreviews": "/api/Spaces-1/releases/Releases-2/deployments/previews/", + "Variables": "/api/Spaces-1/projects/Projects-1/releases/Releases-2/variables" + } + } \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-3/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-3/response.json new file mode 100644 index 0000000000000..7e58acb5fbb48 --- /dev/null +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/releases/Releases-3/response.json @@ -0,0 +1,35 @@ +{ + "Id": "Releases-3", + "SpaceId": "Spaces-1", + "ProjectId": "Projects-1", + "Version": "0.0.2", + "ChannelId": "Channels-1", + "ReleaseNotes": null, + "ProjectDeploymentProcessSnapshotId": "deploymentprocess-Projects-1-s-1", + "IgnoreChannelRules": false, + "BuildInformation": [], + "Assembled": "2024-09-25T14:19:41.123+00:00", + "LibraryVariableSetSnapshotIds": [], + "SelectedPackages": [], + "SelectedGitResources": [], + "ProjectVariableSetSnapshotId": "variableset-Projects-1-s-0", + "VersionControlReference": null, + "Links": { + "Self": "/api/Spaces-1/releases/Releases-3", + "Project": "/api/Spaces-1/projects/Projects-1", + "Channel": "/api/Spaces-1/projects/Projects-1/channels/Channels-1", + "Progression": "/api/Spaces-1/releases/Releases-3/progression", + "Deployments": "/api/Spaces-1/releases/Releases-3/deployments{?skip,take}", + "DeploymentTemplate": "/api/Spaces-1/releases/Releases-3/deployments/template", + "Artifacts": "/api/Spaces-1/artifacts?regarding=Releases-3", + "ProjectVariableSnapshot": "/api/Spaces-1/variables/variableset-Projects-1-s-0", + "ProjectDeploymentProcessSnapshot": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-1-s-1", + "Web": "/app#/Spaces-1/releases/Releases-3", + "SnapshotVariables": "/api/Spaces-1/releases/Releases-3/snapshot-variables", + "Defects": "/api/Spaces-1/releases/Releases-3/defects", + "ReportDefect": "/api/Spaces-1/releases/Releases-3/defects", + "ResolveDefect": "/api/Spaces-1/releases/Releases-3/defects/resolve", + "DeploymentPreviews": "/api/Spaces-1/releases/Releases-3/deployments/previews/", + "Variables": "/api/Spaces-1/projects/Projects-1/releases/Releases-3/variables" + } + } \ No newline at end of file diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/states=Queued,Executing/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/states=Queued,Executing/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/states=Queued,Executing/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/states=Queued,Executing/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/states=Queued,Executing/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/states=Queued,Executing/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-1/states=Queued,Executing/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-1/states=Queued,Executing/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/states=Queued,Executing/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/states=Queued,Executing/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/states=Queued,Executing/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/states=Queued,Executing/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json similarity index 96% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json index 49bdeab0175bb..cf39a3d235ff9 100644 --- a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-2/states=Queued,Executing/skip=0/take=30/response.json @@ -30,9 +30,9 @@ "SpaceId": "Spaces-1", "EstimatedRemainingQueueDurationSeconds": 0, "Name": "Deploy", - "Description": "Deploy hello release 0.0.36 to staging", + "Description": "Deploy hello release 0.0.2 to staging", "Arguments": { - "DeploymentId": "Deployments-111" + "DeploymentId": "Deployments-18" }, "State": "Executing", "Completed": "Executing...", diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=2/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=2/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=2/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=2/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/states=Queued,Executing/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/states=Queued,Executing/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/states=Queued,Executing/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/states=Queued,Executing/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json similarity index 96% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json index dca5a6d5a33a1..e052aa772acb0 100644 --- a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json +++ b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-3/states=Queued,Executing/skip=0/take=30/response.json @@ -30,9 +30,9 @@ "SpaceId": "Spaces-1", "EstimatedRemainingQueueDurationSeconds": 0, "Name": "Deploy", - "Description": "Deploy test release 0.0.41 to dev", + "Description": "Deploy test release 0.0.1 to dev", "Arguments": { - "DeploymentId": "Deployments-118" + "DeploymentId": "Deployments-19" }, "State": "Queued", "Completed": "Queued...", diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:00.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/fromCompletedDate=2024-09-23 14:45:00.123000+00:00/toCompletedDate=2024-09-23 14:45:15.123000+00:00/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/states=Queued,Executing/skip=0/take=2/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/states=Queued,Executing/skip=0/take=2/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/states=Queued,Executing/skip=0/take=2/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/states=Queued,Executing/skip=0/take=2/response.json diff --git a/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/states=Queued,Executing/skip=0/take=30/response.json b/octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/states=Queued,Executing/skip=0/take=30/response.json similarity index 100% rename from octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/project=Projects-4/states=Queued,Executing/skip=0/take=30/response.json rename to octopus_deploy/tests/fixtures/GET/api/Spaces-1/tasks/name=Deploy/project=Projects-4/states=Queued,Executing/skip=0/take=30/response.json diff --git a/octopus_deploy/tests/test_unit.py b/octopus_deploy/tests/test_unit.py index c1162953d1473..9c0ab2dd1cf29 100644 --- a/octopus_deploy/tests/test_unit.py +++ b/octopus_deploy/tests/test_unit.py @@ -200,11 +200,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 'octopus_deploy.deployment.count', 1, tags=[ - 'task_id:ServerTasks-118048', - 'task_name:Deploy', 'task_state:Executing', 'project_name:my-project', 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -212,11 +213,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 'octopus_deploy.deployment.queued_time', 30, tags=[ - 'task_id:ServerTasks-118048', - 'task_name:Deploy', 'task_state:Executing', 'project_name:my-project', 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -224,11 +226,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 'octopus_deploy.deployment.executing_time', 150, tags=[ - 'task_id:ServerTasks-118048', - 'task_name:Deploy', 'task_state:Executing', 'project_name:my-project', 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -237,11 +240,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 0, count=0, tags=[ - 'task_id:ServerTasks-118048', - 'task_name:Deploy', 'task_state:Executing', 'project_name:my-project', 'space_name:Default', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'release_version:0.0.2', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -249,11 +253,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 'octopus_deploy.deployment.count', 1, tags=[ - 'task_id:ServerTasks-118055', - 'task_name:Deploy', 'task_state:Queued', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'release_version:0.0.2', 'server_node:None', ], ) @@ -261,11 +266,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 'octopus_deploy.deployment.queued_time', 60, tags=[ - 'task_id:ServerTasks-118055', - 'task_name:Deploy', 'task_state:Queued', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-19', + 'release_version:0.0.2', + 'environment_name:dev', 'server_node:None', ], ) @@ -274,11 +280,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 0, count=0, tags=[ - 'task_id:ServerTasks-118055', - 'task_name:Deploy', 'task_state:Queued', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-19', + 'release_version:0.0.2', + 'environment_name:dev', 'server_node:None', ], ) @@ -287,11 +294,12 @@ def test_queued_or_running_tasks(get_current_datetime, dd_run_check, aggregator) 0, count=0, tags=[ - 'task_id:ServerTasks-118055', - 'task_name:Deploy', 'task_state:Queued', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-19', + 'release_version:0.0.2', + 'environment_name:dev', 'server_node:None', ], ) @@ -311,8 +319,9 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'project_name:test', 'space_name:Default', 'server_node:None', - 'task_id:ServerTasks-118055', - 'task_name:Deploy', + 'release_version:0.0.2', + 'environment_name:dev', + 'deployment_id:Deployments-19', 'task_state:Queued', ], count=1, @@ -323,8 +332,9 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'space_name:Default', 'project_name:my-project', 'server_node:OctopusServerNodes-50c3dfbarc82', - 'task_id:ServerTasks-118048', - 'task_name:Deploy', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', 'task_state:Executing', ], count=1, @@ -339,11 +349,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.count', 1, tags=[ - 'task_id:ServerTasks-1847', - 'task_name:Deploy', 'task_state:Failed', 'project_name:test', 'space_name:Default', + 'release_version:0.0.2', + 'deployment_id:Deployments-19', + 'environment_name:dev', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -351,11 +362,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.queued_time', 110, tags=[ - 'task_id:ServerTasks-1847', - 'task_name:Deploy', 'task_state:Failed', 'project_name:test', 'space_name:Default', + 'release_version:0.0.2', + 'deployment_id:Deployments-19', + 'environment_name:dev', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -363,11 +375,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.executing_time', 50, tags=[ - 'task_id:ServerTasks-1847', - 'task_name:Deploy', 'task_state:Failed', 'project_name:test', 'space_name:Default', + 'release_version:0.0.2', + 'deployment_id:Deployments-19', + 'environment_name:dev', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -375,11 +388,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.completed_time', 5, tags=[ - 'task_id:ServerTasks-1847', - 'task_name:Deploy', 'task_state:Failed', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'release_version:0.0.2', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -387,11 +401,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.count', 1, tags=[ - 'task_id:ServerTasks-1846', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -399,11 +414,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.queued_time', 90, tags=[ - 'task_id:ServerTasks-1846', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -411,11 +427,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.executing_time', 54, tags=[ - 'task_id:ServerTasks-1846', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-18', + 'release_version:0.0.1', + 'environment_name:staging', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -423,22 +440,24 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.completed_time', 1, tags=[ - 'task_id:ServerTasks-1846', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) aggregator.assert_metric( 'octopus_deploy.deployment.count', tags=[ - 'task_id:ServerTasks-1845', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -446,11 +465,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.queued_time', 18, tags=[ - 'task_id:ServerTasks-1845', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -458,11 +478,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.executing_time', 41, tags=[ - 'task_id:ServerTasks-1845', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -470,11 +491,12 @@ def test_completed_tasks(get_current_datetime, dd_run_check, aggregator): 'octopus_deploy.deployment.completed_time', 14, tags=[ - 'task_id:ServerTasks-1845', - 'task_name:Deploy', 'task_state:Success', 'project_name:test', 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', 'server_node:OctopusServerNodes-50c3dfbarc82', ], ) @@ -965,6 +987,836 @@ def test_events(get_current_datetime, dd_run_check, aggregator, expected_events, aggregator.assert_event(event['message'], tags=event['tags'], count=1) +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_environment_metrics(get_current_datetime, dd_run_check, aggregator): + instance = {'octopus_endpoint': 'http://localhost:80'} + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + dd_run_check(check) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=1, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_environments_discovery_one_include(get_current_datetime, dd_run_check, aggregator): + instance = {'octopus_endpoint': 'http://localhost:80', 'environments': {'include': ['dev']}} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + dd_run_check(check) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + count=0, + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + count=0, + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=1, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + count=0, + ) + + aggregator.assert_metric_has_tag("octopus_deploy.deployment.count", 'environment_name:dev') + aggregator.assert_metric_has_tag("octopus_deploy.deployment.count", 'environment_name:staging', count=0) + + +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_environments_discovery_exclude_dev(get_current_datetime, dd_run_check, aggregator): + instance = {'octopus_endpoint': 'http://localhost:80', 'environments': {'exclude': ['dev'], 'include': ['.*']}} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + dd_run_check(check) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=1, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + aggregator.assert_metric_has_tag("octopus_deploy.deployment.count", 'environment_name:dev', count=0) + aggregator.assert_metric_has_tag("octopus_deploy.deployment.count", 'environment_name:staging') + + +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_environments_discovery_include_invalid(get_current_datetime, dd_run_check, aggregator): + instance = {'octopus_endpoint': 'http://localhost:80', 'environments': {'include': ['test']}} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + dd_run_check(check) + env_metrics = aggregator.metrics('octopus_deploy.environment.count') + assert len(env_metrics) == 0 + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + count=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + count=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=1, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=0, + count=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + aggregator.assert_metric_has_tag("octopus_deploy.deployment.count", 'environment_name:dev', count=0) + aggregator.assert_metric_has_tag("octopus_deploy.deployment.count", 'environment_name:staging', count=0) + + +@pytest.mark.parametrize( + ('mock_http_get', 'expected_log'), + [ + pytest.param( + { + 'http_error': { + '/api/Spaces-1/environments': MockResponse(status_code=500), + } + }, + 'Failed to access endpoint: api/Spaces-1/environments: 500 Server Error: None for url: None', + id='http error', + ), + ], + indirect=['mock_http_get'], +) +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_environments_metrics_http_failure(get_current_datetime, dd_run_check, aggregator, expected_log, caplog): + instance = {'octopus_endpoint': 'http://localhost:80', 'environments': {'include': ['test']}} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + caplog.set_level(logging.WARNING) + dd_run_check(check) + env_metrics = aggregator.metrics('octopus_deploy.environment.count') + assert len(env_metrics) == 0 + assert expected_log in caplog.text + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.count', + value=1, + count=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.use_guided_failure', + value=0, + count=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=1, + count=0, + tags=['space_name:Default', 'environment_name:dev', 'environment_slug:dev', 'environment_id:Environments-1'], + ) + aggregator.assert_metric( + 'octopus_deploy.environment.allow_dynamic_infrastructure', + value=0, + count=0, + tags=[ + 'space_name:Default', + 'environment_name:staging', + 'environment_slug:staging', + 'environment_id:Environments-2', + ], + ) + + +@pytest.mark.parametrize( + ('mock_http_get', 'expected_log'), + [ + pytest.param( + { + 'http_error': { + '/api/Spaces-1/releases/Releases-3': MockResponse(status_code=500), + } + }, + 'Failed to access endpoint: api/Spaces-1/releases/Releases-3: 500 Server Error: None for url: None', + id='http error', + ), + ], + indirect=['mock_http_get'], +) +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_deployment_metrics_releases_http_failure(get_current_datetime, dd_run_check, aggregator, expected_log, caplog): + instance = {'octopus_endpoint': 'http://localhost:80'} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + caplog.set_level(logging.WARNING) + dd_run_check(check) + + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + tags=[ + 'project_name:test', + 'space_name:Default', + 'server_node:None', + 'release_version:None', + 'environment_name:dev', + 'deployment_id:Deployments-19', + 'task_state:Queued', + ], + count=1, + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + tags=[ + 'space_name:Default', + 'project_name:my-project', + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', + 'task_state:Executing', + ], + count=1, + ) + deployment_metrics = aggregator.metrics('octopus_deploy.deployment.count') + assert len(deployment_metrics) == 2 + assert expected_log in caplog.text + get_current_datetime.return_value = MOCKED_TIME2 + dd_run_check(check) + + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + 1, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'release_version:None', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.queued_time', + 110, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'release_version:None', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.executing_time', + 50, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'release_version:None', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.completed_time', + 5, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'release_version:None', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + 1, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.queued_time', + 90, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.executing_time', + 54, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'release_version:0.0.1', + 'environment_name:staging', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.completed_time', + 1, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:staging', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.queued_time', + 18, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.executing_time', + 41, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.completed_time', + 14, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + + +@pytest.mark.parametrize( + ('mock_http_get', 'expected_log'), + [ + pytest.param( + { + 'http_error': { + '/api/Spaces-1/deployments/Deployments-18': MockResponse(status_code=500), + } + }, + 'Failed to access endpoint: api/Spaces-1/deployments/Deployments-18: 500 Server Error: None for url: None', + id='http error', + ), + ], + indirect=['mock_http_get'], +) +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_deployment_metrics_deployments_http_failure( + get_current_datetime, dd_run_check, aggregator, expected_log, caplog +): + instance = {'octopus_endpoint': 'http://localhost:80'} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + caplog.set_level(logging.DEBUG) + dd_run_check(check) + + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + tags=[ + 'project_name:test', + 'space_name:Default', + 'server_node:None', + 'release_version:0.0.2', + 'environment_name:dev', + 'deployment_id:Deployments-19', + 'task_state:Queued', + ], + count=1, + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + tags=[ + 'space_name:Default', + 'project_name:my-project', + 'server_node:OctopusServerNodes-50c3dfbarc82', + 'deployment_id:Deployments-18', + 'environment_name:None', + 'release_version:None', + 'task_state:Executing', + ], + count=0, + ) + deployment_metrics = aggregator.metrics('octopus_deploy.deployment.count') + assert len(deployment_metrics) == 1 + assert expected_log in caplog.text + get_current_datetime.return_value = MOCKED_TIME2 + dd_run_check(check) + + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + 1, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'release_version:0.0.2', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.queued_time', + 110, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'release_version:0.0.2', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.executing_time', + 50, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'release_version:0.0.2', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.completed_time', + 5, + tags=[ + 'task_state:Failed', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-19', + 'environment_name:dev', + 'release_version:0.0.2', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + 1, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:None', + 'release_version:None', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + count=0, + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.queued_time', + 90, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:None', + 'release_version:None', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + count=0, + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.executing_time', + 54, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'release_version:None', + 'environment_name:None', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + count=0, + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.completed_time', + 1, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-18', + 'environment_name:None', + 'release_version:None', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + count=0, + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.queued_time', + 18, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.executing_time', + 41, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + aggregator.assert_metric( + 'octopus_deploy.deployment.completed_time', + 14, + tags=[ + 'task_state:Success', + 'project_name:test', + 'space_name:Default', + 'deployment_id:Deployments-17', + 'environment_name:dev', + 'release_version:0.0.1', + 'server_node:OctopusServerNodes-50c3dfbarc82', + ], + ) + + +@pytest.mark.parametrize( + ('mock_http_get', 'expected_log'), + [ + pytest.param( + { + 'http_error': { + '/api/Spaces-1/environments': MockResponse(status_code=500), + } + }, + 'Failed to access endpoint: api/Spaces-1/environments: 500 Server Error: None for url: None', + id='http error', + ), + ], + indirect=['mock_http_get'], +) +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_deployment_metrics_environments_http_failure( + get_current_datetime, dd_run_check, aggregator, expected_log, caplog +): + instance = {'octopus_endpoint': 'http://localhost:80', 'environments': {'include': ['test']}} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + caplog.set_level(logging.WARNING) + dd_run_check(check) + assert expected_log in caplog.text + get_current_datetime.return_value = MOCKED_TIME2 + dd_run_check(check) + + aggregator.assert_metric( + 'octopus_deploy.deployment.count', + count=0, + ) + + +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_deployments_caching(get_current_datetime, dd_run_check, mock_http_get): + instance = {'octopus_endpoint': 'http://localhost:80'} + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + get_current_datetime.return_value = MOCKED_TIME1 + dd_run_check(check) + get_current_datetime.return_value = MOCKED_TIME2 + dd_run_check(check) + dd_run_check(check) + dd_run_check(check) + dd_run_check(check) + + args_list = [] + for call in mock_http_get.call_args_list: + args, _ = call + args_list += list(args) + + assert args_list.count('http://localhost:80/api/Spaces-1/releases/Releases-1') == 1 + assert args_list.count('http://localhost:80/api/Spaces-1/releases/Releases-2') == 1 + assert args_list.count('http://localhost:80/api/Spaces-1/releases/Releases-3') == 1 + + assert args_list.count('http://localhost:80/api/Spaces-1/deployments/Deployments-17') == 1 + assert args_list.count('http://localhost:80/api/Spaces-1/deployments/Deployments-18') == 1 + assert args_list.count('http://localhost:80/api/Spaces-1/deployments/Deployments-19') == 1 + + assert args_list.count('http://localhost:80/api/Spaces-1/environments') == 5 + + @pytest.mark.parametrize( ('paginated_limit'), [pytest.param(30, id='high limit'), pytest.param(2, id='low limit')], @@ -984,6 +1836,8 @@ def test_paginated_limit_octopusservernodes( args_list = [] for call in mock_http_get.call_args_list: + args, _ = call + args_list += list(args) args, kwargs = call take = kwargs.get('params', {}).get('take') skip = kwargs.get('params', {}).get('skip') @@ -1272,3 +2126,50 @@ def test_paginated_limit_tasks( skip_take_args += [(list(args), skip, take)] assert skip_take_args == expected_skip_take_args + + +@pytest.mark.parametrize( + ('paginated_limit, expected_skip_take_args'), + [ + pytest.param( + 30, + [ + (['http://localhost:80/api/Spaces-1/environments'], 0, 30), + ], + id='high limit', + ), + pytest.param( + 2, + [ + (['http://localhost:80/api/Spaces-1/environments'], 0, 2), + ], + id='low limit', + ), + ], +) +@pytest.mark.usefixtures('mock_http_get') +@mock.patch("datadog_checks.octopus_deploy.check.get_current_datetime") +def test_paginated_limit_environments( + get_current_datetime, + dd_run_check, + paginated_limit, + mock_http_get, + expected_skip_take_args, +): + instance = {'octopus_endpoint': 'http://localhost:80'} + instance['paginated_limit'] = paginated_limit + + check = OctopusDeployCheck('octopus_deploy', {}, [instance]) + + get_current_datetime.return_value = MOCKED_TIME1 + dd_run_check(check) + + skip_take_args = [] + for call in mock_http_get.call_args_list: + args, kwargs = call + take = kwargs.get('params', {}).get('take') + skip = kwargs.get('params', {}).get('skip') + if 'http://localhost:80/api/Spaces-1/environments' == args[0]: + skip_take_args += [(list(args), skip, take)] + + assert skip_take_args == expected_skip_take_args