conde-nast-international / tftest

Terraform Testing Tool
Other
0 stars 1 forks source link

Cannot run embedded tests locally. #48

Open tomgco opened 6 years ago

tomgco commented 6 years ago

Module to test:

 module "staging_etcd_cluster_health" {
-  source = "git@github.com:conde-nast-international/cnid-terraform-modules.git//datadog-monitoring/etcd/cluster-healthy?ref=2.6.1"
+  # source = "git@github.com:conde-nast-international/cnid-terraform-modules.git//datadog-monitoring/etcd/cluster-healthy?ref=2.6.1"
+  source = "../../../../../cnid-terraform-modules/datadog-monitoring/etcd/cluster-healthy"
   env    = "staging"

   thresholds = {
@@ -92,3 +93,15 @@ module "staging_etcd_cluster_append_requests" {

   alert_handles = "@slack-staging-alarms @slack-devops-notifications"
 }
+
+module "staging_etcd_composite_member" {
+  # source = "git@github.com:conde-nast-international/cnid-terraform-modules.git//datadog-monitoring/etcd/cluster-qps?ref=2.5.0"
+  source = "../../../../../cnid-terraform-modules/datadog-monitoring/composite"
+  env    = "staging"
+
+  alert_handles = "@slack-staging-alarms @slack-devops-notifications"
+  query = "${module.staging_etcd_cluster_health.id}"
+  alert_message = "A cluster member is experiencing an event"
+  name = "Cluster Member Event"
+  resource = "etcd"
+}

Required naming inside modules.js for it to pick up tests.

+++ b/azimuth/staging/eu-central-1/datadog/modules.js
@@ -1,4 +1,5 @@
 module.exports = [
+  { name: '../../../../../cnid-terraform-modules/datadog-monitoring/composite', prefix: 'staging_etcd_composite_member' },
   { name: 'datadog-monitoring/kube_unavailable_pods', prefix: 'flyway_staging_unavailable_pods' },
   { name: 'datadog-monitoring/kube_no_pods_for_deployment', prefix: 'flyway_staging_unavailable_dashboard' },
   { name: 'datadog-monitoring/kube_no_pods_for_deployment', prefix: 'flyway_staging_unavailable_dashboard_api' }
diff --git a/azimuth/staging/eu-central-1/datadog/tests.js b/azimuth/staging/eu-central-1/datadog/tests.js
index 4de5644..f74f168 100644
--- a/azimuth/staging/eu-central-1/datadog/tests.js
+++ b/azimuth/staging/eu-central-1/datadog/tests.js
@@ -30,5 +30,16 @@ module.exports = [{
       expect(obj.destroy).toBe(false);
     }
   ]
+},
+{
+  'name': 'staging_etcd_composite_member.datadog_monitor.composite',
+  'description': 'prevents destroy of an alarm',
+  'count': 1,
+  'args': {},
+  'tests': [
+    function (obj, args) {
+      expect(obj.destroy).toBe(false);
+    }
+  ]

Without the full path, which we had to manually grab and parse ourselves, the tests within the module (not the ones we wrote) didn't run.

tomgco commented 6 years ago

The module name shouldn't be ../../../../../cnid-terraform-modules/datadog-monitoring/composite