Skip to content

Commit

Permalink
Paralel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ujstor committed Jun 20, 2024
1 parent 6bd234c commit b761b7e
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 29 deletions.
78 changes: 51 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ aws eks update-kubeconfig --region <REGION> --name <EKS_CLUSTER_NAME>
```bash
cd modules/test
go test -v -timeout 30m
go test -v -timeout 30m -run TestHelloWorldAppExample
go test -v -timeout 30m -parallel 2
```

## Dir structure
Expand All @@ -58,9 +60,9 @@ go test -v -timeout 30m
│ ├── [4.0K] ghAction/
│ │ ├── [1.6K] main.tf
│ │ ├── [ 535] outputs.tf
│ │ ├── [ 337] terraform.tf
│ │ ├── [ 411] terraform.tf
│ │ ├── [ 992] tf-apply.yml
│ │ └── [ 305] variables.tf
│ │ └── [ 308] variables.tf
│ ├── [4.0K] iam/
│ │ ├── [1.2K] main.tf
│ │ ├── [1.7K] outputs.tf
Expand All @@ -73,20 +75,38 @@ go test -v -timeout 30m
│ └── [ 330] variables.tf
├── [4.0K] modules/
│ ├── [4.0K] examples/
│ │ └── [4.0K] asg/
│ │ └── [4.0K] one-instance/
│ │ ├── [ 697] main.tf
│ │ ├── [ 111] outputs.tf
│ │ ├── [ 202] terraform.tf
│ │ └── [ 79] variables.tf
│ │ ├── [4.0K] alb/
│ │ │ ├── [ 207] dependencies.tf
│ │ │ ├── [ 177] main.tf
│ │ │ ├── [ 382] outputs.tf
│ │ │ ├── [ 320] terraform.tf
│ │ │ ├── [5.9K] terraform.tfstate
│ │ │ ├── [ 181] terraform.tfstate.backup
│ │ │ └── [ 116] variables.tf
│ │ ├── [4.0K] asg/
│ │ │ └── [4.0K] one-instance/
│ │ │ ├── [ 439] dependencies.tf
│ │ │ ├── [ 370] main.tf
│ │ │ ├── [ 111] outputs.tf
│ │ │ ├── [ 321] terraform.tf
│ │ │ └── [ 79] variables.tf
│ │ └── [4.0K] hello-world-app/
│ │ └── [4.0K] standalone/
│ │ ├── [ 721] dependencies.tf
│ │ ├── [ 422] main.tf
│ │ ├── [ 109] outputs.tf
│ │ ├── [ 319] terraform.tf
│ │ ├── [ 29K] terraform.tfstate
│ │ ├── [1.0K] terraform.tfstate.backup
│ │ └── [ 625] variables.tf
│ ├── [4.0K] modules/
│ │ ├── [4.0K] cluster/
│ │ │ └── [4.0K] asg-rolling-deploy/
│ │ │ ├── [ 80] dependencies.tf
│ │ │ ├── [3.5K] main.tf
│ │ │ ├── [ 274] outputs.tf
│ │ │ ├── [ 159] terraform.tf
│ │ │ └── [1.4K] variables.tf
│ │ │ └── [1.9K] variables.tf
│ │ ├── [4.0K] data-stores/
│ │ │ └── [4.0K] mysql/
│ │ │ ├── [ 669] main.tf
Expand All @@ -98,7 +118,7 @@ go test -v -timeout 30m
│ │ │ ├── [2.3K] main.tf
│ │ │ ├── [ 517] outputs.tf
│ │ │ ├── [ 159] terraform.tf
│ │ │ └── [1015] variables.tf
│ │ │ └── [ 583] variables.tf
│ │ ├── [4.0K] k8s/
│ │ │ ├── [1.3K] main.tf
│ │ │ ├── [ 368] outputs.tf
Expand All @@ -112,54 +132,58 @@ go test -v -timeout 30m
│ │ │ └── [ 187] variables.tf
│ │ └── [4.0K] services/
│ │ └── [4.0K] hello-world-app/
│ │ ├── [ 348] dependencies.tf
│ │ ├── [1.5K] main.tf
│ │ ├── [ 797] dependencies.tf
│ │ ├── [1.4K] main.tf
│ │ ├── [ 389] outputs.tf
│ │ ├── [ 159] terraform.tf
│ │ ├── [ 168] user-data.sh
│ │ └── [1.8K] variables.tf
│ │ └── [2.0K] variables.tf
│ └── [4.0K] test/
│ ├── [ 870] alb_example_test.go
│ ├── [2.6K] go.mod
│ ├── [ 94K] go.sum
│ └── [1.0K] hello_world_test.go
├── [4.0K] packer/
│ ├── [ 576] webserver.json
│ └── [ 724] webserver.json.pkr.hcl
├── [4.0K] prod/
│ ├── [4.0K] data-stores/
│ │ └── [4.0K] mysql/
│ │ ├── [ 533] main.tf
│ │ ├── [ 626] main.tf
│ │ ├── [ 783] output.tf
│ │ ├── [ 671] terraform.tf
│ │ ├── [ 712] terraform.tf
│ │ └── [ 265] variables.tf
│ └── [4.0K] services/
│ ├── [4.0K] eks-cluster/
│ │ ├── [ 81] dependencies.tf
│ │ ├── [ 528] main.tf
│ │ ├── [ 693] main.tf
│ │ ├── [ 257] outputs.tf
│ │ └── [ 735] terraform.tf
│ │ └── [ 776] terraform.tf
│ └── [4.0K] hello-world-app/
│ ├── [ 202] dependencies.tf
│ ├── [ 517] main.tf
│ ├── [ 572] main.tf
│ ├── [ 111] outputs.tf
│ └── [ 497] terraform.tf
│ └── [ 538] terraform.tf
├── [4.0K] stage/
│ ├── [4.0K] data-stores/
│ │ └── [4.0K] mysql/
│ │ ├── [ 296] main.tf
│ │ ├── [ 389] main.tf
│ │ ├── [ 337] output.tf
│ │ ├── [ 607] terraform.tf
│ │ ├── [ 648] terraform.tf
│ │ └── [ 266] variables.tf
│ └── [4.0K] services/
│ ├── [4.0K] hello-world-app/
│ │ ├── [ 202] dependencies.tf
│ │ ├── [ 538] main.tf
│ │ ├── [ 587] main.tf
│ │ ├── [ 109] outputs.tf
│ │ ├── [ 615] terraform.tf
│ │ └── [ 121] variables.tf
│ │ └── [ 656] terraform.tf
│ └── [4.0K] k8s/
│ ├── [ 341] main.tf
│ ├── [ 420] main.tf
│ ├── [ 127] outputs.tf
│ └── [ 530] terraform.tf
│ └── [ 571] terraform.tf
├── [1.0K] LICENSE.txt
└── [4.5K] README.md
├── [5.7K] README.md
└── [ 180] terraform.tfstate
```

## License
Expand Down
2 changes: 1 addition & 1 deletion modules/examples/alb/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "alb" {
aws = aws.snadbox
}

alb_name = "alb-sandbox-test"
alb_name = var.alb_name
subnet_ids = data.aws_subnets.default.ids
}

5 changes: 5 additions & 0 deletions modules/examples/alb/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "alb_name" {
description = "Name of the ALB"
type = string
default = "alb-sandbox-test"
}
2 changes: 1 addition & 1 deletion modules/examples/hello-world-app/standalone/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "hello-world-app" {
aws = aws.snadbox
}

environment = "snadbox"
environment = var.environment
image_id = data.aws_ami.ubuntu.id
instance_type = "t2.micro"

Expand Down
5 changes: 5 additions & 0 deletions modules/examples/hello-world-app/standalone/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ variable "subnet_ids" {
default = null
}

variable "environment" {
description = "The name of the environment we're deploying to"
type = string
default = "snadbox-hello-world-example"
}
5 changes: 5 additions & 0 deletions modules/test/alb_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import (
"time"

"github.com/gruntwork-io/terratest/modules/http-helper"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/gruntwork-io/terratest/modules/terraform"
)

func TestAlbExample(t *testing.T) {
t.Parallel()

opts := &terraform.Options{
TerraformDir: "../examples/alb",
Vars: map[string]interface{}{
"alb_name": fmt.Sprintf("test-alb-%s", random.UniqueId()),
},
}

defer terraform.Destroy(t, opts)
Expand Down
4 changes: 4 additions & 0 deletions modules/test/hello_world_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ import (
"time"

"github.com/gruntwork-io/terratest/modules/http-helper"
"github.com/gruntwork-io/terratest/modules/random"
"github.com/gruntwork-io/terratest/modules/terraform"
)

func TestHelloWorldAppExample(t *testing.T) {
t.Parallel()

opts := &terraform.Options{
TerraformDir: "../examples/hello-world-app/standalone",
Vars: map[string]interface{}{
"mysql_config": map[string]interface{}{
"address": "mock-value-for-test",
"port": 3306,
},
"environment": fmt.Sprintf("test-hw-app-%s", random.UniqueId()),
},
}

Expand Down

0 comments on commit b761b7e

Please sign in to comment.