-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate Docker for E2E testing with Makefile and Azure pipeline orc…
…hestration
- Loading branch information
1 parent
7e77b10
commit 83d260f
Showing
5 changed files
with
234 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# ./templates/e2e-pipeline-template.yml | ||
parameters: | ||
- name: rpImageACR | ||
type: string | ||
- name: acrCredentialsJSON | ||
type: string | ||
|
||
steps: | ||
# Authenticate to ACR and Install Docker Compose | ||
- task: AzureCLI@2 | ||
displayName: 'Authenticate to ACR and Install Docker Compose' | ||
inputs: | ||
azureSubscription: 'ado-pipeline-dev-image-push' # Replace with your service connection | ||
scriptType: bash | ||
scriptLocation: 'inlineScript' | ||
inlineScript: | | ||
set -xe | ||
# Ensure RP_IMAGE_ACR is correctly passed as a parameter | ||
if [ -z "${{ parameters.rpImageACR }}" ]; then | ||
echo "Error: RP_IMAGE_ACR is not set" | ||
exit 1 | ||
fi | ||
ACR_FQDN="${{ parameters.rpImageACR }}" | ||
REGISTRY_NAME=$(echo $ACR_FQDN | cut -d'.' -f1) | ||
# Install Docker Compose | ||
sudo apt-get update | ||
sudo apt-get install -y docker-compose | ||
# Login to ACR | ||
az acr login --name $REGISTRY_NAME | ||
# Pull the RP Docker image | ||
- script: | | ||
if [ -z "${{ parameters.rpImageACR }}" ]; then | ||
echo "Error: RP_IMAGE_ACR is not set" | ||
exit 1 | ||
fi | ||
export RP_IMAGE_ACR=${{ parameters.rpImageACR }} | ||
export VERSION=$(Build.BuildId) | ||
docker pull ${RP_IMAGE_ACR}/aro:${VERSION} | ||
displayName: Pull RP Docker Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Use a Microsoft-approved image | ||
FROM mcr.microsoft.com/azure-cli:2.61.0 AS base | ||
|
||
# Install OpenVPN | ||
RUN apk add --no-cache openvpn || tdnf install -y openvpn || dnf install -y openvpn | ||
|
||
# Create the config directory and generate a basic vpn.conf file | ||
RUN mkdir -p /etc/openvpn && echo "client\nremote vpn-server-address 1194\nproto udp\ndev tun\nresolv-retry infinite\nnobind\npersist-key\npersist-tun\nca ca.crt\ncert client.crt\nkey client.key\ncomp-lzo\nverb 3" > /etc/openvpn/vpn.conf | ||
|
||
# Run OpenVPN when the container starts | ||
CMD ["openvpn", "--config", "/etc/openvpn/vpn.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
version: '3.8' | ||
|
||
services: | ||
vpn: | ||
image: ${RP_IMAGE_ACR}/vpn_image:${VERSION} | ||
container_name: vpn-container | ||
privileged: true | ||
network_mode: host # Use host networking for OpenVPN to access the host network | ||
command: "sudo openvpn --config /etc/openvpn/vpn.conf" # OpenVPN command | ||
healthcheck: | ||
test: ["CMD-SHELL", "ping -c 1 google.com || exit 1"] # Basic health check for VPN | ||
interval: 30s | ||
timeout: 10s | ||
retries: 3 | ||
|
||
selenium: | ||
image: selenium/standalone-chrome | ||
container_name: selenium-container | ||
network_mode: host # Use host networking for Selenium to communicate with other services | ||
ports: | ||
- "4444:4444" | ||
healthcheck: | ||
test: "curl -f http://localhost:4444 || exit 1" # Health check to ensure Selenium is running | ||
interval: 30s | ||
timeout: 10s | ||
retries: 3 | ||
|
||
rp: | ||
image: ${RP_IMAGE_ACR}/aro:${VERSION} | ||
container_name: rp-container | ||
network_mode: host # Use host networking to ensure RP can communicate | ||
healthcheck: | ||
test: "curl -f http://localhost:8443/healthz || exit 1" # Health check to ensure RP is running | ||
interval: 30s | ||
timeout: 10s | ||
retries: 3 | ||
environment: | ||
- CI=true | ||
- RESOURCEGROUP=${RESOURCEGROUP} | ||
- CLUSTER=${CLUSTER} | ||
|
||
e2e: | ||
image: ${RP_IMAGE_ACR}/aro:${VERSION} | ||
container_name: e2e-container | ||
network_mode: host # Use host networking to ensure E2E can reach services | ||
depends_on: | ||
rp: | ||
condition: service_healthy # Wait until RP is healthy | ||
environment: | ||
- CI=true | ||
- LOCATION=${LOCATION} | ||
- CLUSTER=${CLUSTER} | ||
- AZURE_TENANT_ID=${AZURE_TENANT_ID} | ||
- AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID} | ||
- AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET} | ||
- AZURE_CLIENT_ID=${AZURE_CLIENT_ID} | ||
- E2E_FLAGS=${E2E_FLAGS} | ||
- E2E_LABEL=${E2E_LABEL} | ||
entrypoint: ["/usr/local/bin/e2e.test"] # Override ENTRYPOINT to run e2e.test binary | ||
command: ["${E2E_FLAGS}", "--ginkgo.label-filter=${E2E_LABEL}"] # Override CMD to pass arguments | ||
|
||
networks: | ||
default: | ||
external: true # Ensure host network is used |