Skip to content

Maintenance: End-to-End testing work only on eu-west-1 region #1083

Closed
@ijemmy

Description

@ijemmy

Bug description

Running AWS_PROFILE=MY_PROFILE_NAME AWS_REGION=eu-central-1 npm run test:e2e doesn't put all test stacks on eu-central-1. Instead, it deploys all logger tests on eu-west-1 for logger and tracer

This is not consistent in all packages. E2E tests are deployed to eu-central-1 for metrics. Given that, I suspect that this from populateEnvironmentVariables.ts as both files are in logger and tracer, and it override process.env.AWS_REGION.

Stacks deployed on eu-west-1
image

Stacks deployed on eu-central-1
image

# For testing on individual package
# Deployed to incorrect region
cd packages/logger/tests/e2e
AWS_PROFILE=MY_PROFILE_NAME AWS_REGION=eu-central-1 npx jest --group=e2e/logger 
cd ../../../tracer/tests/e2e
AWS_PROFILE=MY_PROFILE_NAME AWS_REGION=eu-central-1 npx jest --group=e2e/tracer 

# Deployed to correct region 
cd ../../../metrics/tests/e2e
AWS_PROFILE=MY_PROFILE_NAME AWS_REGION=eu-central-1 npx jest --group=e2e/metrics/decorator

Expected Behavior

It should have deployed test stacks on eu-central-1

Current Behavior

It deploys logger and tracer test stacks on eu-west-1. Only metrics test stacks are deployed to eu-central-1

Possible Solution

A simple fix is to remove process.env.AWS_REGION assignment. However, this value is used for unit testing (at least in logger). The unit testing assume that the log output will have eu-west-1 as a region. So the options to fix this issue are either:

  1. Remove the assignment. And make all unit tests verify input based on current process.env.AWS_REGION instead of hardcoded value.
  2. Add if condition to the assignment, use eu-west-1 if running on unit testing mode or e2e testing mode when AWS_REGION is not provided.

Option 1 seems more attractive to me. But I am not 100% sure if this better. The implementor should evaluate theses two options or find a better one.

Steps to Reproduce

  1. cd packages/logger/tests/e2e
  2. DISABLE_TEARDOWN=false AWS_PROFILE=MY_PROFILE_NAME AWS_REGION=eu-central-1 npx jest --group=e2e/logger
  3. Check in console if it's deployed in eu-central-1. (It should not)

Repeat the same steps for tracer

Environment

  • Powertools version used: 1.2.1
  • Packaging format (Layers, npm): npm
  • AWS Lambda function runtime: N/A
  • Debugging logs: N/A

Related issues, RFCs

N/A

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedtestsPRs that add or change tests

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions