From 358e1abc265db659d158618ebaffd5268f67aa89 Mon Sep 17 00:00:00 2001 From: Garland Kan Date: Wed, 23 Mar 2022 12:57:20 -0700 Subject: [PATCH] testkube (#274) --- .../aws/kubernetes/manifest_set/main.tf | 5 +++++ .../aws/kubernetes/manifest_set/variables.tf | 11 +++++++++++ .../base-tests/test-suites/infra-base/main.tf | 6 ++++++ .../yaml/alert-manager-slack-config.yaml | 18 ++++++++++++++++++ .../infra-base/yaml/prometheus-endpoint.yaml | 18 ++++++++++++++++++ .../test-suites/infra-base/yaml/ts.yaml | 19 +++++++++++++++++++ 6 files changed, 77 insertions(+) create mode 100644 terraform-modules/aws/kubernetes/manifest_set/main.tf create mode 100644 terraform-modules/aws/kubernetes/manifest_set/variables.tf create mode 100644 terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf create mode 100644 terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/alert-manager-slack-config.yaml create mode 100644 terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/prometheus-endpoint.yaml create mode 100644 terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/ts.yaml diff --git a/terraform-modules/aws/kubernetes/manifest_set/main.tf b/terraform-modules/aws/kubernetes/manifest_set/main.tf new file mode 100644 index 000000000..a00a294b7 --- /dev/null +++ b/terraform-modules/aws/kubernetes/manifest_set/main.tf @@ -0,0 +1,5 @@ +# Uploads all of the files in the pass in dir path and subdirectories +resource "kubernetes_manifest" "this" { + for_each = fileset(var.upload_directory, "**/*.*") + manifest = yamldecode(file("${var.upload_source_path}/${var.upload_directory}/${each.value}")) +} diff --git a/terraform-modules/aws/kubernetes/manifest_set/variables.tf b/terraform-modules/aws/kubernetes/manifest_set/variables.tf new file mode 100644 index 000000000..953d758c7 --- /dev/null +++ b/terraform-modules/aws/kubernetes/manifest_set/variables.tf @@ -0,0 +1,11 @@ +variable "upload_directory" { + type = string + default = "yaml" + description = "Just the directory name containing the folder to recursively apply from." +} + +variable "upload_source_path" { + type = string + default = "path.cwd" + description = "The full path to where the directory var.upload_directory resides (not including the var.upload_directory dir name)." +} diff --git a/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf new file mode 100644 index 000000000..edc4af454 --- /dev/null +++ b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf @@ -0,0 +1,6 @@ +module "manifest_set" { + source = "github.com/ManagedKube/kubernetes-ops.git//terraform-modules/aws/kubernetes/manifest_set?ref=gha-testkube" + + upload_source_path = path.cwd + upload_directory = "yaml" +} diff --git a/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/alert-manager-slack-config.yaml b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/alert-manager-slack-config.yaml new file mode 100644 index 000000000..8fdb2a4cd --- /dev/null +++ b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/alert-manager-slack-config.yaml @@ -0,0 +1,18 @@ +apiVersion: tests.testkube.io/v2 +kind: Test +metadata: + name: infra-base-alertmanager-slack-config + namespace: testkube +spec: + content: + data: | + { + "command": [ + "curl", + "http://alertmanager-operated.monitoring.svc:9093/api/v2/status" + ], + "expected_status": "200", + "expected_body": "slack_configs" + } + type: string + type: curl/test \ No newline at end of file diff --git a/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/prometheus-endpoint.yaml b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/prometheus-endpoint.yaml new file mode 100644 index 000000000..02597b047 --- /dev/null +++ b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/prometheus-endpoint.yaml @@ -0,0 +1,18 @@ +apiVersion: tests.testkube.io/v2 +kind: Test +metadata: + name: infra-base-prometheus-endpoint + namespace: testkube +spec: + content: + data: | + { + "command": [ + "curl", + "http://prometheus-operated.monitoring.svc:9090/-/ready" + ], + "expected_status": "200", + "expected_body": "Prometheus is Ready." + } + type: string + type: curl/test \ No newline at end of file diff --git a/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/ts.yaml b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/ts.yaml new file mode 100644 index 000000000..addf4bac7 --- /dev/null +++ b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/yaml/ts.yaml @@ -0,0 +1,19 @@ +apiVersion: tests.testkube.io/v1 +kind: TestSuite +metadata: + name: infra-base + namespace: testkube +spec: + description: Infra testsuite + steps: + - execute: + name: infra-base-prometheus-endpoint + namespace: testkube + type: testExecution + # - delay: + # duration: 2000 + # type: delay + - execute: + name: infra-base-alertmanager-slack-config + namespace: testkube + type: testExecution