Skip to content

Commit

Permalink
Add e2e canary to public preview regions (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrryr authored Nov 30, 2023
1 parent 9d3b384 commit 9747047
Show file tree
Hide file tree
Showing 26 changed files with 193 additions and 122 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/appsignals-e2e-ec2-canary-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ permissions:

jobs:
e2e-canary-test:
strategy:
fail-fast: false
matrix:
aws-region: ['us-east-1', 'us-east-2', 'eu-west-1', 'ap-northeast-1', 'ap-southeast-2']
uses: ./.github/workflows/appsignals-e2e-ec2-test.yml
secrets: inherit
with:
aws-region: ${{ matrix.aws-region }}
caller-workflow-name: 'appsignals-e2e-ec2-canary-test'
13 changes: 12 additions & 1 deletion .github/workflows/appsignals-e2e-ec2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: App Signals Enablement E2E Testing - EC2 Use Case
on:
workflow_call:
inputs:
aws-region:
required: true
type: string
caller-workflow-name:
required: true
type: string
Expand All @@ -14,7 +17,7 @@ permissions:
contents: read

env:
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_REGION: ${{ inputs.aws-region }} # Used by terraform and AWS CLI commands
TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}
SAMPLE_APP_FRONTEND_SERVICE_JAR: "s3://aws-appsignals-sample-app/main-service.jar"
SAMPLE_APP_REMOTE_SERVICE_JAR: "s3://aws-appsignals-sample-app/remote-service.jar"
Expand Down Expand Up @@ -58,6 +61,11 @@ jobs:
-var="cw_agent_rpm=${{ env.APP_SIGNALS_CW_AGENT_RPM }}" \
-var="adot_jar=${{ env.APP_SIGNALS_ADOT_JAR }}"
- name: Get the ec2 instance ami id
run: |
echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
working-directory: testing/terraform/ec2

- name: Get the sample app endpoint
run: |
echo "MAIN_SERVICE_ENDPOINT=$(terraform output sample_app_main_service_public_dns):8080" >> $GITHUB_ENV
Expand Down Expand Up @@ -103,6 +111,7 @@ jobs:
--service-name sample-application-${{ env.TESTING_ID }}
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
--request-body ip=${{ env.REMOTE_SERVICE_IP }}
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
--rollup'

- name: Validate generated metrics
Expand All @@ -119,6 +128,7 @@ jobs:
--service-name sample-application-${{ env.TESTING_ID }}
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
--request-body ip=${{ env.REMOTE_SERVICE_IP }}
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
--rollup'

- name: Validate generated traces
Expand All @@ -135,6 +145,7 @@ jobs:
--service-name sample-application-${{ env.TESTING_ID }}
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
--request-body ip=${{ env.REMOTE_SERVICE_IP }}
--instance-ami ${{ env.EC2_INSTANCE_AMI }}
--rollup'

- name: Publish metric on test result
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/appsignals-e2e-eks-canary-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ permissions:
contents: read

jobs:
e2e-canary-test:
e2e-test:
strategy:
fail-fast: false
matrix:
aws-region: ['us-east-1', 'us-east-2', 'eu-west-1', 'ap-northeast-1', 'ap-southeast-2']
uses: ./.github/workflows/appsignals-e2e-eks-test.yml
secrets: inherit
with:
aws-region: ${{ matrix.aws-region }}
test-cluster-name: 'e2e-canary-test'
caller-workflow-name: 'appsignals-e2e-eks-canary-test'
16 changes: 10 additions & 6 deletions .github/workflows/appsignals-e2e-eks-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: App Signals Enablement E2E Testing - EKS
on:
workflow_call:
inputs:
aws-region:
required: true
type: string
test-cluster-name:
required: true
type: string
Expand All @@ -20,7 +23,7 @@ permissions:
contents: read

env:
AWS_DEFAULT_REGION: us-east-1
AWS_DEFAULT_REGION: ${{ inputs.aws-region }} # Used by terraform and AWS CLI commands
TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}
ENABLEMENT_SCRIPT_S3_BUCKET: ${{ secrets.APP_SIGNALS_E2E_ENABLEMENT_SCRIPT }}
SAMPLE_APP_NAMESPACE: sample-app-namespace
Expand All @@ -30,15 +33,15 @@ env:
LOG_GROUP_NAME: /aws/appsignals/eks

jobs:
appsignals-e2e-test:
e2e-eks-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate testing id
run: echo TESTING_ID="${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
run: echo TESTING_ID="${{ env.AWS_DEFAULT_REGION }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down Expand Up @@ -87,6 +90,7 @@ jobs:
terraform validate
terraform apply -auto-approve \
-var="test_id=${{ env.TESTING_ID }}" \
-var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
-var="kube_directory_path=${{ github.workspace }}/.kube" \
-var="eks_cluster_name=${{ inputs.test-cluster-name }}" \
-var="eks_cluster_context_name=$(kubectl config current-context)" \
Expand Down Expand Up @@ -167,7 +171,7 @@ jobs:
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
--app-namespace ${{ env.SAMPLE_APP_NAMESPACE }}
--cluster ${{ inputs.test-cluster-name }}
--platform-info ${{ inputs.test-cluster-name }}
--service-name sample-application-${{ env.TESTING_ID }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_DEPLOYMENT_NAME }}
--request-body ip=${{ env.REMOTE_SERVICE_POD_IP }}
Expand All @@ -184,7 +188,7 @@ jobs:
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
--app-namespace ${{ env.SAMPLE_APP_NAMESPACE }}
--cluster ${{ inputs.test-cluster-name }}
--platform-info ${{ inputs.test-cluster-name }}
--service-name sample-application-${{ env.TESTING_ID }}
--remote-service-name sample-remote-application-${{ env.TESTING_ID }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_DEPLOYMENT_NAME }}
Expand All @@ -202,7 +206,7 @@ jobs:
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
--app-namespace ${{ env.SAMPLE_APP_NAMESPACE }}
--cluster ${{ inputs.test-cluster-name }}
--platform-info ${{ inputs.test-cluster-name }}
--service-name sample-application-${{ env.TESTING_ID }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_DEPLOYMENT_NAME }}
--request-body ip=${{ env.REMOTE_SERVICE_POD_IP }}
Expand Down
32 changes: 30 additions & 2 deletions testing/terraform/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,36 @@ locals {
private_key_content = tls_private_key.ssh_key.private_key_pem
}

data "aws_ami" "ami" {
executable_users = ["self"]
most_recent = true
filter {
name = "architecture"
values = ["x86_64"]
}
filter {
name = "image-type"
values = ["machine"]
}

filter {
name = "root-device-name"
values = ["/dev/xvda"]
}

filter {
name = "root-device-type"
values = ["ebs"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}
}

resource "aws_instance" "main_service_instance" {
ami = "ami-0b021814637c6d457" # Amazon Linux 2 (free tier)
ami = data.aws_ami.ami.id # Amazon Linux 2 (free tier)
instance_type = "t2.micro"
key_name = local.ssh_key_name
iam_instance_profile = "APP_SIGNALS_EC2_TEST_ROLE"
Expand Down Expand Up @@ -88,7 +116,7 @@ resource "null_resource" "main_service_setup" {
}

resource "aws_instance" "remote_service_instance" {
ami = "ami-0b021814637c6d457" # Amazon Linux 2 (free tier)
ami = data.aws_ami.ami.id # Amazon Linux 2 (free tier)
instance_type = "t2.micro"
key_name = local.ssh_key_name
iam_instance_profile = "APP_SIGNALS_EC2_TEST_ROLE"
Expand Down
4 changes: 4 additions & 0 deletions testing/terraform/ec2/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ output "sample_app_main_service_public_dns" {

output "sample_app_remote_service_public_ip" {
value = aws_instance.remote_service_instance.public_ip
}

output "ec2_instance_ami" {
value = data.aws_ami.ami.id
}
2 changes: 1 addition & 1 deletion testing/terraform/eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
}

provider "aws" {
region = "us-east-1"
region = var.aws_region
}

# get eks cluster
Expand Down
4 changes: 4 additions & 0 deletions testing/terraform/eks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ variable "kube_directory_path" {
default = "./.kube"
}

variable "aws_region" {
default = "<e.g. us-east-1>"
}

variable "eks_cluster_name" {
default = "<cluster-name>"
}
Expand Down
12 changes: 9 additions & 3 deletions testing/validator/src/main/java/com/amazon/aoc/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class App implements Callable<Integer> {
private String appNamespace;

@CommandLine.Option(
names = {"--cluster"},
names = {"--platform-info"},
defaultValue = "demo-cluster")
private String cluster;
private String platformInfo;

@CommandLine.Option(
names = {"--service-name"},
Expand Down Expand Up @@ -133,6 +133,11 @@ public class App implements Callable<Integer> {
defaultValue = "true")
private boolean isRollup;

@CommandLine.Option(
names = {"--instance-ami"},
defaultValue = "")
private String instanceAmi;

private static final String TEST_CASE_DIM_KEY = "testcase";
private static final String CANARY_NAMESPACE = "Otel/Canary";
private static final String CANARY_METRIC_NAME = "Success";
Expand All @@ -151,7 +156,7 @@ public Integer call() throws Exception {
context.setAvailabilityZone(this.availabilityZone);
context.setMetricNamespace(this.metricNamespace);
context.setAppNamespace(this.appNamespace);
context.setCluster(this.cluster);
context.setPlatformInfo(this.platformInfo);
context.setServiceName(this.serviceName);
context.setRemoteServiceName(this.remoteServiceName);
context.setRemoteServiceDeploymentName(this.remoteServiceDeploymentName);
Expand All @@ -166,6 +171,7 @@ public Integer call() throws Exception {
context.setCortexInstanceEndpoint(this.cortexInstanceEndpoint);
context.setTestcase(testcase);
context.setLanguage(language);
context.setInstanceAmi(this.instanceAmi);

log.info(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class Context {

private String appNamespace;

private String cluster;
// Variable containing platform specific information. Ex: For EKS, the cluster where the sample
// app is deployed is needed.
private String platformInfo;

private String serviceName;

Expand All @@ -53,6 +55,8 @@ public class Context {

private String logGroup;

private String instanceAmi;

private ECSContext ecsContext;

private CloudWatchContext cloudWatchContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {
"default": {
"otel.resource.aws.hostedin.environment": "^EC2$",
"otel.resource.host.image.id": "^ami-0b021814637c6d457$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t2.micro$",
"aws.span.kind": "^LOCAL_ROOT$"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"metadata": {
"default": {
"otel.resource.aws.hostedin.environment": "^EC2$",
"otel.resource.host.image.id": "^ami-0b021814637c6d457$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t2.micro$"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {
"default": {
"otel.resource.aws.hostedin.environment": "^EC2$",
"otel.resource.host.image.id": "^ami-0b021814637c6d457$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t2.micro$",
"aws.span.kind": "^LOCAL_ROOT$"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {
"default": {
"otel.resource.aws.hostedin.environment": "^EC2$",
"otel.resource.host.image.id": "^ami-0b021814637c6d457$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t2.micro$",
"aws.span.kind": "^LOCAL_ROOT$"
}
Expand Down Expand Up @@ -69,7 +69,7 @@
"metadata": {
"default": {
"otel.resource.aws.hostedin.environment": "^EC2$",
"otel.resource.host.image.id": "^ami-0b021814637c6d457$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t2.micro$",
"aws.span.kind": "^LOCAL_ROOT$"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[{
"HostedIn.EKS.Cluster": "^{{cluster}}$",
"HostedIn.EKS.Cluster": "^{{platformInfo}}$",
"HostedIn.K8s.Namespace": "^{{appNamespace}}$",
"K8s.Node": "^i-[A-Za-z0-9]{17}$",
"K8s.Pod": "^sample-(remote-)?app-deployment(-[A-Za-z0-9]*)*$",
Expand All @@ -10,7 +10,7 @@
"aws.span.kind": "^LOCAL_ROOT$"
},
{
"HostedIn.EKS.Cluster": "^{{cluster}}$",
"HostedIn.EKS.Cluster": "^{{platformInfo}}$",
"HostedIn.K8s.Namespace": "^{{appNamespace}}$",
"K8s.Node": "^i-[A-Za-z0-9]{17}$",
"K8s.Pod": "^sample-app-deployment(-[A-Za-z0-9]*)*$",
Expand Down
Loading

0 comments on commit 9747047

Please sign in to comment.