Skip to content

Commit c9496eb

Browse files
committed
DO NOT MERGE Test aws integration on localstack API
1 parent cc58daf commit c9496eb

File tree

9 files changed

+117
-53
lines changed

9 files changed

+117
-53
lines changed

.buildkite/pipeline.trigger.integration.tests.sh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,37 @@ STACK_COMMAND_TESTS=(
1818
test-stack-command-8x
1919
)
2020

21-
for test in ${STACK_COMMAND_TESTS[@]}; do
22-
echo " - label: \":go: Running integration test: ${test}\""
23-
echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}"
24-
echo " agents:"
25-
echo " provider: \"gcp\""
26-
echo " artifact_paths:"
27-
echo " - build/elastic-stack-dump/stack/*/logs/*.log"
28-
echo " - build/elastic-stack-dump/stack/*/logs/fleet-server-internal/**/*"
29-
echo " - build/elastic-stack-status/*/*"
30-
done
21+
# for test in ${STACK_COMMAND_TESTS[@]}; do
22+
# echo " - label: \":go: Running integration test: ${test}\""
23+
# echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}"
24+
# echo " agents:"
25+
# echo " provider: \"gcp\""
26+
# echo " artifact_paths:"
27+
# echo " - build/elastic-stack-dump/stack/*/logs/*.log"
28+
# echo " - build/elastic-stack-dump/stack/*/logs/fleet-server-internal/**/*"
29+
# echo " - build/elastic-stack-status/*/*"
30+
# done
3131

3232
CHECK_PACKAGES_TESTS=(
3333
test-check-packages-other
3434
test-check-packages-with-kind
3535
test-check-packages-with-custom-agent
3636
test-check-packages-benchmarks
3737
)
38-
for test in ${CHECK_PACKAGES_TESTS[@]}; do
39-
echo " - label: \":go: Running integration test: ${test}\""
40-
echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}"
41-
echo " agents:"
42-
echo " provider: \"gcp\""
43-
echo " artifact_paths:"
44-
echo " - build/test-results/*.xml"
45-
echo " - build/elastic-stack-dump/stack/check-*/logs/*.log"
46-
echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/**/*"
47-
echo " - build/elastic-stack-status/*/*"
48-
if [[ $test =~ with-kind$ ]]; then
49-
echo " - build/kubectl-dump.txt"
50-
fi
51-
done
38+
# for test in ${CHECK_PACKAGES_TESTS[@]}; do
39+
# echo " - label: \":go: Running integration test: ${test}\""
40+
# echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}"
41+
# echo " agents:"
42+
# echo " provider: \"gcp\""
43+
# echo " artifact_paths:"
44+
# echo " - build/test-results/*.xml"
45+
# echo " - build/elastic-stack-dump/stack/check-*/logs/*.log"
46+
# echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/**/*"
47+
# echo " - build/elastic-stack-status/*/*"
48+
# if [[ $test =~ with-kind$ ]]; then
49+
# echo " - build/kubectl-dump.txt"
50+
# fi
51+
# done
5252

5353
pushd test/packages/parallel > /dev/null
5454
for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ test-check-packages-benchmarks:
8181
PACKAGE_TEST_TYPE=benchmarks ./scripts/test-check-packages.sh
8282

8383
test-check-packages-parallel:
84-
PACKAGE_TEST_TYPE=parallel ./scripts/test-check-packages.sh
84+
PACKAGE_TEST_TYPE=parallel PACKAGE_UNDER_TEST=aws ./scripts/test-check-packages.sh
8585

8686
test-check-packages-with-custom-agent:
8787
PACKAGE_TEST_TYPE=with-custom-agent ./scripts/test-check-packages.sh
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "3.8"
2+
services:
3+
localstack:
4+
container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
5+
image: localstack/localstack
6+
hostname: localstack
7+
ports:
8+
- "4566:4566" # LocalStack Gateway
9+
environment:
10+
- SERVICES=sqs,sns
11+
- DEBUG=1
12+
- DOCKER_HOST=unix:///var/run/docker.sock
13+
- HOST_TMP_FOLDER=${TMPDIR}
14+
- HOSTNAME_EXTERNAL=localstack
15+
- S3_HOSTNAME=localstack
16+
volumes:
17+
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
18+
- "/var/run/docker.sock:/var/run/docker.sock"

internal/testrunner/runners/system/servicedeployer/_static/terraform_deployer_run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ trap cleanup EXIT INT TERM
2121
terraform init
2222
terraform plan
2323
terraform apply -auto-approve && touch /tmp/tf-applied
24+
terraform output -json
2425

2526
echo "Terraform definitions applied."
2627

internal/testrunner/runners/system/servicedeployer/terraform.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ import (
2424
const (
2525
terraformDeployerDir = "terraform"
2626
terraformDeployerYml = "terraform-deployer.yml"
27+
localstackDeployerYml = "localstack-deployer.yml"
2728
terraformDeployerDockerfile = "Dockerfile"
2829
terraformDeployerRun = "run.sh"
2930
)
3031

32+
//go:embed _static/localstack_deployer.yml
33+
var localstackDeployerYmlContent string
34+
3135
//go:embed _static/terraform_deployer.yml
3236
var terraformDeployerYmlContent string
3337

@@ -59,12 +63,21 @@ func (tsd TerraformServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedServic
5963
}
6064

6165
ymlPaths := []string{filepath.Join(configDir, terraformDeployerYml)}
66+
67+
localstackYmlPath := filepath.Join(configDir, localstackDeployerYml)
68+
_, err = os.Stat(localstackYmlPath)
69+
if err == nil {
70+
ymlPaths = append(ymlPaths, localstackYmlPath)
71+
}
72+
6273
envYmlPath := filepath.Join(tsd.definitionsDir, envYmlFile)
6374
_, err = os.Stat(envYmlPath)
6475
if err == nil {
6576
ymlPaths = append(ymlPaths, envYmlPath)
6677
}
6778

79+
logger.Debug("Print the yml Paths %s", ymlPaths)
80+
6881
tfEnvironment := tsd.buildTerraformExecutorEnvironment(inCtxt)
6982

7083
service := dockerComposeDeployedService{
@@ -130,6 +143,11 @@ func (tsd TerraformServiceDeployer) installDockerfile() (string, error) {
130143
tfDir := filepath.Join(locationManager.DeployerDir(), terraformDeployerDir)
131144

132145
resources := []resource.Resource{
146+
&resource.File{
147+
Path: localstackDeployerYml,
148+
Content: resource.FileContentLiteral(localstackDeployerYmlContent),
149+
CreateParent: true,
150+
},
133151
&resource.File{
134152
Path: terraformDeployerYml,
135153
Content: resource.FileContentLiteral(terraformDeployerYmlContent),

test/packages/parallel/aws/data_stream/ec2_metrics/_dev/deploy/tf/env.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@ version: '2.3'
22
services:
33
terraform:
44
environment:
5-
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
6-
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
7-
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
8-
- AWS_PROFILE=${AWS_PROFILE}
95
- AWS_REGION=${AWS_REGION:-us-east-1}

test/packages/parallel/aws/data_stream/ec2_metrics/_dev/deploy/tf/main.tf

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,62 @@ variable "TEST_RUN_ID" {
33
}
44

55
provider "aws" {
6-
default_tags {
7-
tags = {
8-
environment = var.ENVIRONMENT
9-
repo = var.REPO
10-
branch = var.BRANCH
11-
build = var.BUILD_ID
12-
created_date = var.CREATED_DATE
13-
}
6+
access_key = "test"
7+
secret_key = "test"
8+
region = "us-east-1"
9+
s3_use_path_style = true
10+
skip_credentials_validation = true
11+
skip_metadata_api_check = true
12+
skip_requesting_account_id = true
13+
14+
endpoints {
15+
apigateway = "http://localstack:4566"
16+
apigatewayv2 = "http://localstack:4566"
17+
cloudformation = "http://localstack:4566"
18+
cloudwatch = "http://localstack:4566"
19+
dynamodb = "http://localstack:4566"
20+
ec2 = "http://localstack:4566"
21+
es = "http://localstack:4566"
22+
elasticache = "http://localstack:4566"
23+
firehose = "http://localstack:4566"
24+
iam = "http://localstack:4566"
25+
kinesis = "http://localstack:4566"
26+
lambda = "http://localstack:4566"
27+
rds = "http://localstack:4566"
28+
redshift = "http://localstack:4566"
29+
route53 = "http://localstack:4566"
30+
s3 = "http://localstack:4566"
31+
secretsmanager = "http://localstack:4566"
32+
ses = "http://localstack:4566"
33+
sns = "http://localstack:4566"
34+
sqs = "http://localstack:4566"
35+
ssm = "http://localstack:4566"
36+
stepfunctions = "http://localstack:4566"
37+
sts = "http://localstack:4566"
1438
}
1539
}
1640

17-
resource "aws_instance" "i" {
18-
ami = data.aws_ami.latest-amzn.id
19-
monitoring = true
20-
instance_type = "t1.micro"
41+
resource "aws_s3_bucket" "elastic_package_aws_test_bucket" {
42+
bucket = "my-tf-test-bucket"
43+
2144
tags = {
22-
Name = "elastic-package-test-${var.TEST_RUN_ID}"
45+
environment = var.ENVIRONMENT
46+
repo = var.REPO
47+
branch = var.BRANCH
48+
build = var.BUILD_ID
49+
created_date = var.CREATED_DATE
2350
}
2451
}
2552

26-
data "aws_ami" "latest-amzn" {
27-
most_recent = true
28-
owners = [ "amazon" ] # AWS
29-
filter {
30-
name = "name"
31-
values = ["amzn2-ami-minimal-hvm-*-ebs"]
53+
resource "aws_instance" "elastic_package_aws_test_ec2" {
54+
ami = "ami-0d57c0143330e1fa7"
55+
instance_type = "t2.micro"
56+
57+
tags = {
58+
environment = var.ENVIRONMENT
59+
repo = var.REPO
60+
branch = var.BRANCH
61+
build = var.BUILD_ID
62+
created_date = var.CREATED_DATE
3263
}
3364
}

test/packages/parallel/aws/data_stream/ec2_metrics/_dev/deploy/tf/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
variable "BRANCH" {
22
description = "Branch name or pull request for tagging purposes"
3-
default = "unknown-branch"
3+
default = "unknown-branch"
44
}
55

66
variable "BUILD_ID" {
77
description = "Build ID in the CI for tagging purposes"
8-
default = "unknown-build"
8+
default = "unknown-build"
99
}
1010

1111
variable "CREATED_DATE" {
1212
description = "Creation date in epoch time for tagging purposes"
13-
default = "unknown-date"
13+
default = "unknown-date"
1414
}
1515

1616
variable "ENVIRONMENT" {

test/packages/parallel/aws/data_stream/ec2_metrics/_dev/test/system/test-default-config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ vars:
55
session_token: '{{AWS_SESSION_TOKEN}}'
66
data_stream:
77
vars:
8-
period: 5m
9-
latency: 10m
8+
period: 1m
9+
latency: 1m
1010
tags_filter: |-
1111
- key: Name
1212
value: "elastic-package-test-{{TEST_RUN_ID}}"

0 commit comments

Comments
 (0)