Skip to content

Commit

Permalink
Compose stack
Browse files Browse the repository at this point in the history
  • Loading branch information
flurdy committed Nov 28, 2024
1 parent 5d51f15 commit 04d7488
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 47 deletions.
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
cdp-portal-journey-tests
# cdp-portal-journey-tests

The template to create a service that runs WDIO tests against an environment.
Testing CDP Portal.

- [Requirements](#requirements)
- [Node.js](#nodejs)
WDIO tests against an environment, github workflow or locally.

- [Related Tests](#related-tests)
- [Local](#local)
- [Requirements](#requirements)
- [Node.js](#nodejs)
- [Setup](#setup)
- [Running local tests](#running-local-tests)
- [Debugging local tests](#debugging-local-tests)
Expand All @@ -15,6 +18,19 @@ The template to create a service that runs WDIO tests against an environment.

## Local Development

### Requirements

#### Node.js

Please install [Node.js](http://nodejs.org/) `>= v20` and [npm](https://nodejs.org/) `>= v9`. You will find it
easier to use the Node Version Manager [nvm](https://github.com/creationix/nvm)

To use the correct version of Node.js for this application, via nvm:

```bash
nvm use
```

### Setup

Install application dependencies:
Expand All @@ -25,7 +41,10 @@ npm install

### Running local tests

Start application you are testing on the url specified in `baseUrl` [wdio.local.conf.js](wdio.local.conf.js)
1. Edit [wdio.local.conf.js](wdio.local.conf.js) and set `baseUrl` to your service under test.

1. Start application you are testing on the url specified in `baseUrl`


```bash
npm run test:local
Expand Down
143 changes: 109 additions & 34 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
interval: 5s
start_period: 5s
retries: 3

################################################################################
localstack:
image: localstack/localstack:3.2.0
Expand Down Expand Up @@ -70,39 +71,113 @@ services:
# Add the services you want to test below.
#
################################################################################
# cdp-example-node-frontend:
# image: defradigital/cdp-example-node-frontend:latest
# env_file:
# - ./docker/config/defaults.env
# - ./docker/config/example-frontend.env
# environment:
# - PORT=3000
# depends_on:
# cdp-example-node-backend:
# condition: service_started
# redis:
# condition: service_healthy
# ports:
# - 3000:3000
# healthcheck:
# test: ["CMD", "curl", "http://localhost:3000/health"]
# interval: 3s
# start_period: 2s
# retries: 3
cdp-portal-frontend:
image: defradigital/cdp-portal-frontend:latest
env_file:
- ./docker/config/defaults.env
- ./docker/config/portal-frontend.env
environment:
- PORT=3000
depends_on:
cdp-portal-backend:
condition: service_started
cdp-self-service-ops:
condition: service_started
cdp-user-service-backend:
condition: service_started
redis:
condition: service_healthy
ports:
- 3000:3000
healthcheck:
test: ["CMD", "curl", "http://localhost:3000/health"]
interval: 3s
start_period: 2s
retries: 3

################################################################################
cdp-portal-backend:
image: defradigital/cdp-portal-backend:latest
ports:
- 5094:5094
env_file:
- ./docker/config/defaults.env
- ./docker/config/portal-backend.env
environment:
- PORT=5094
depends_on:
localstack:
condition: service_healthy
mongodb:
condition: service_healthy
cdp-self-service-ops:
condition: service_started
cdp-user-service-backend:
condition: service_started

################################################################################
# cdp-example-node-backend:
# image: defradigital/cdp-example-node-backend:latest
# env_file:
# - ./docker/config/defaults.env
# - ./docker/config/example-backend.env
# environment:
# - PORT=3001
# depends_on:
# mongodb:
# condition: service_healthy
# healthcheck:
# test: ["CMD", "curl", "http://localhost:3001/health"]
# interval: 3s
# start_period: 2s
# retries: 3
cdp-user-service-backend:
image: defradigital/cdp-user-service-backend:latest
ports:
- 3001:3001
env_file:
- ./config/defaults.env
- ./config/cdp-user-service-backend.env
environment:
- PORT=3001
depends_on:
localstack:
condition: service_healthy
mongodb:
condition: service_started
healthcheck:
test: ["CMD", "curl", "http://localhost:3001/health"]
interval: 3s
start_period: 2s
retries: 3

################################################################################
cdp-self-service-ops:
image: defradigital/cdp-self-service-ops:latest
ports:
- 3009:3009
env_file:
- ./config/defaults.env
- ./config/cdp-self-service-ops.env
environment:
- PORT=3009
depends_on:
localstack:
condition: service_healthy
mongodb:
condition: service_started
healthcheck:
test: ["CMD", "curl", "http://localhost:3009/health"]
interval: 3s
start_period: 2s
retries: 3

################################################################################
cdp-portal-stubs:
image: defradigital/cdp-portal-stubs:latest
env_file:
- ./config/defaults.env
- ./config/cdp-portal-stubs.env
ports:
- 3939:3939
environment:
- PORT=3939
- OIDC_SHOW_LOGIN=true
depends_on:
localstack:
condition: service_healthy
mongodb:
condition: service_started
redis:
condition: service_started
healthcheck:
test: ["CMD", "echo", "Y29uc3QgZT1yZXF1aXJlKCJodHRwIiksdD17aG9zdG5hbWU6ImxvY2FsaG9zdCIscG9ydDpwcm9jZXNzLmVudi5QT1JULHBhdGg6Ii9oZWFsdGgiLG1ldGhvZDoiR0VUIn0sbz1lLnJlcXVlc3QodCwoZT0+e2xldCB0PSIiO2Uub24oImRhdGEiLChlPT57dCs9ZX0pKSxlLm9uKCJlbmQiLCgoKT0+e3Byb2Nlc3MuZXhpdCgwKX0pKX0pKTtvLm9uKCJlcnJvciIsKGU9Pntwcm9jZXNzLmV4aXQoMSl9KSksby5lbmQoKTsK", "|", "base64", "-d", "|", "node", "-"]
interval: 3s
start_period: 2s
profiles:
- portal
15 changes: 15 additions & 0 deletions docker/config/cdp-portal-backend.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Github__ApiUrl=http://localhost:3939
# This is a mock app key
# $ ssh-keygen -t rsa -b 4096 -m PEM -f /tmp/mock.key -q -P "" && cat /tmp/mock.key | base64 -w0
Github__AppKey=...

ASPNETCORE_ENVIRONMENT=Development
Docker__RegistryUrl=http://localhost:3939
Github__PollIntervalSecs=10

UserServiceBackendUrl=http://localhost:3001

LocalStack__Config__LocalStackHost=localhost
SqsLocalServiceUrl=http://localhost:4566
EcsEvents__QueueUrl=http://localhost:4566/000000000000/ecs-deployments
EcrEvents__QueueUrl=http://localhost:4566/000000000000/ecr-push-events
3 changes: 3 additions & 0 deletions docker/config/cdp-portal-frontend.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_BASE_URL=http://localhost:3000
USE_SINGLE_INSTANCE_CACHE=true
TERMINAL_PROXY_URL=http://localhost:8085
7 changes: 7 additions & 0 deletions docker/config/cdp-portal-stubs.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
OIDC_BASE_PATH=/63983fc2-cfff-45bb-8ec2-959e21062b9a/v2.0
OIDC_SHOW_LOGIN=false
# OIDC_PUBLIC_KEY_B64=...

# random key for local testing
# OIDC_PRIVATE_KEY_B64=...
1 change: 1 addition & 0 deletions docker/config/cdp-self-service-ops.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SQS_GITHUB_QUEUE=http://localstack:4566/000000000000/github-events
1 change: 1 addition & 0 deletions docker/config/cdp-user-service-backend.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AZURE_CLIENT_BASE_URL=http://localhost:3939/msgraph/
17 changes: 11 additions & 6 deletions docker/config/defaults.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# MongoDB
MONGO_URI=mongodb://mongodb:27017/?tls=false
Mongo__DatabaseUri=mongodb://mongodb:27017/?tls=false
MONGO_URI=mongodb://localhost:27017/?tls=false
Mongo__DatabaseUri=mongodb://localhost:27017/?tls=false

# Redis
REDIS_HOST=redis
USE_SINGLE_INSTANCE_CACHE=true

# Localstack/AWS
LOCALSTACK_URL=http://localstack:4566
SNS_ENDPOINT=http://localstack:4566
SQS_ENDPOINT=http://localstack:4566
S3_ENDPOINT=http://localstack:4566
LOCALSTACK_URL=http://localhost:4566
SNS_ENDPOINT=http://localhost:4566
SQS_ENDPOINT=http://localhost:4566
S3_ENDPOINT=http://localhost:4566

AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
Expand All @@ -19,3 +19,8 @@ AWS_REGION=eu-west-2

# Placeholder trust store cert
TRUSTSTORE_CDP_ROOT_CA=LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUI5akNDQVYrZ0F3SUJBZ0lVS1I4MkxndGtOQmNjZHlwWUQyNks4N3paK3ZZd0RRWUpLb1pJaHZjTkFRRUUKQlFBd0RURUxNQWtHQTFVRUN3d0NSVkF3SGhjTk1Ua3dPVEkyTURJd05EVXlXaGNOTVRreE1ESTJNREl3TkRVeQpXakFOTVFzd0NRWURWUVFMREFKRlVEQ0JuekFOQmdrcWhraUc5dzBCQVFFRkFBT0JqUUF3Z1lrQ2dZRUF3S3ZhCk5aQ09HY3VZOTAvQnVkUytxUWljK0EzMXVNOG1MdG1JNjBSMWlFamdFV0dCQ3hTaURiMmg4bVFKaVh3a3VsOVcKZWJhYXpQN2hrcWtkTm9KZ1YvNk5FNysrR0t5eVM4ZkloSmdlV1NiNkVlbE1GaGpRMG5aS3piWlg1bXMzSTkxbgp0d3prY0h0S0NRaS9naS9Sb3VobGsvUC9RVmNyelNnSFVIcUpOeTBDQXdFQUFhTlRNRkV3SFFZRFZSME9CQllFCkZISGJncW5uaG0zR0FKNGd5Mkl1RUR4cEx5ZTdNQjhHQTFVZEl3UVlNQmFBRkhIYmdxbm5obTNHQUo0Z3kySXUKRUR4cEx5ZTdNQThHQTFVZEV3RUIvd1FGTUFNQkFmOHdEUVlKS29aSWh2Y05BUUVFQlFBRGdZRUFHNUNvcWNFeQoxNXZVcGo1VmZKZVIvRFM3MHRQSWlucC9UQ0M5a1JPLysrVFNuUGJxVmNmUHI4dkl5YzRMM01QS2pYRkJzZWZFCnZ0ZkhHR3VjVnR2NU4xKzRVL2I5TnhORmJ1SDJNUDdXM3N3WjRXTTcyTmErVzZpT2h3ZXNPcjBwM0ljT2Z4YzMKUk5DbmFnRm10YkRGeEFsUFhRMGQrbStONWd4TFJvQ1gxaEU9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K

GITHUB_BASE_URL=http://localhost:3939
PORTAL_BACKEND_URL=http://localhost:5094
SELF_SERVICE_OPS_URL=http://localhost:3009
USER_SERVICE_BACKEND_URL=http://localhost:3001
1 change: 0 additions & 1 deletion docker/config/example-backend.env

This file was deleted.

1 change: 0 additions & 1 deletion docker/config/example-frontend.env

This file was deleted.

0 comments on commit 04d7488

Please sign in to comment.