Skip to content

Commit 1148111

Browse files
committed
test: add integration setup step
This adds a setup step to the pipeline before the integration tests are executed, ensuring that long-running resources are created before the tests run.
1 parent a0712b8 commit 1148111

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

.github/workflows/tests.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,33 @@ jobs:
6565
name: lint-report
6666
path: lint-report.xml
6767

68+
run-setup:
69+
name: Run Integration Setup
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: ⬇️ Check out code into the Go module directory
73+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
74+
75+
- name: 🛠️ Setup Terraform
76+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
77+
with:
78+
terraform_wrapper: false
79+
80+
- name: 🚀 Integration Setup - Terraform Init
81+
working-directory: ./testsetup
82+
run: terraform init
83+
84+
- name: 🚀 Integration Setup - Terraform Apply
85+
working-directory: ./testsetup
86+
env:
87+
TF_VAR_DYNATRACE_ENV_URL: ${{ secrets.DYNATRACE_ENV_URL }}
88+
TF_VAR_DYNATRACE_API_TOKEN: ${{ secrets.DYNATRACE_API_TOKEN }}
89+
run: terraform apply -auto-approve
90+
6891
integration-tests:
6992
name: Integration Tests - ${{ matrix.config.name }}
7093
runs-on: ubuntu-latest
94+
needs: [ run-setup ]
7195
strategy:
7296
fail-fast: false
7397
matrix:

testsetup/mobile_application.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
locals {
2+
mobile_application_name = "Application"
3+
}
4+
5+
data "dynatrace_mobile_application" "setup_application" {
6+
name = local.mobile_application_name
7+
}
8+
9+
import {
10+
to = dynatrace_mobile_application.application
11+
for_each = try(data.dynatrace_mobile_application.setup_application.id, null) == null ? [] : [data.dynatrace_mobile_application.setup_application.id]
12+
id = each.value
13+
}
14+
15+
resource "dynatrace_mobile_application" "application" {
16+
name = local.mobile_application_name
17+
beacon_endpoint_type = "INSTRUMENTED_WEB_SERVER"
18+
beacon_endpoint_url = "https://dynatrace.com/dtmb"
19+
application_type = "MOBILE_APPLICATION"
20+
user_session_percentage = 100
21+
apdex {
22+
frustrated = 12000
23+
frustrated_on_error = true
24+
tolerable = 3000
25+
}
26+
27+
lifecycle {
28+
prevent_destroy = true
29+
}
30+
}

testsetup/provider.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_providers {
3+
dynatrace = {
4+
source = "dynatrace-oss/dynatrace"
5+
version = "~>1.90.0"
6+
}
7+
}
8+
}
9+
10+
provider "dynatrace" {
11+
dt_env_url = var.DYNATRACE_ENV_URL
12+
dt_api_token = var.DYNATRACE_API_TOKEN
13+
}

testsetup/synthetic_location.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
locals {
2+
location_name = "Location"
3+
}
4+
5+
data "dynatrace_synthetic_location" "location" {
6+
name = local.location_name
7+
}
8+
9+
import {
10+
to = dynatrace_synthetic_location.location
11+
for_each = try(data.dynatrace_synthetic_location.location.id, null) == null ? [] : [data.dynatrace_synthetic_location.location.id]
12+
id = each.value
13+
}
14+
15+
resource "dynatrace_synthetic_location" "location" {
16+
name = local.location_name
17+
city = "San Francisco de Asis"
18+
country_code = "VE"
19+
region_code = "04"
20+
deployment_type = "STANDARD"
21+
latitude = 10.0756
22+
location_node_outage_delay_in_minutes = 3
23+
longitude = -67.5442
24+
25+
lifecycle {
26+
prevent_destroy = true
27+
}
28+
}

testsetup/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "DYNATRACE_API_TOKEN" {
2+
type = string
3+
description = "Dynatrace API Token with appropriate permissions."
4+
sensitive = true
5+
}
6+
7+
variable "DYNATRACE_ENV_URL" {
8+
type = string
9+
description = "Dynatrace Environment URL."
10+
}

0 commit comments

Comments
 (0)