Skip to content

Commit

Permalink
fixed the vpn issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhadapaithankar committed Oct 11, 2024
1 parent c3b0bd6 commit 018d0c2
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 93 deletions.
188 changes: 97 additions & 91 deletions .pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,147 +26,153 @@ variables:
- name: VERSION
value: $(Build.BuildId)

jobs:
- job: Build_Test_And_Push_Az_ARO_Extension
pool:
name: 1es-aro-ci-pool
steps:
- template: ./templates/template-checkout.yml

# Build and test the Az ARO Extension
- script: |
set -xe
DOCKER_BUILD_CI_ARGS="--load" make ci-azext-aro VERSION=$(VERSION)
displayName: 🛠 Build & Test Az ARO Extension
# Push the image to ACR
- template: ./templates/template-acr-push.yml
parameters:
acrFQDN: 'arosvcdev.azurecr.io'
repository: 'azext-aro'
pushLatest: true

- job: Build_And_Test_RP_And_Portal
pool:
name: 1es-aro-ci-pool
steps:
- template: ./templates/template-checkout.yml

# Build and test RP and Portal
- script: |
set -xe
DOCKER_BUILD_CI_ARGS="--load" make ci-rp VERSION=$(VERSION)
displayName: 🛠 Build & Test RP and Portal
# Publish test results
- task: PublishTestResults@2
displayName: 📊 Publish tests results
inputs:
testResultsFiles: $(System.DefaultWorkingDirectory)/report.xml
condition: succeededOrFailed()

# Publish code coverage results
- task: PublishCodeCoverageResults@2
displayName: 📈 Publish code coverage
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage.xml
failIfCoverageEmpty: false
condition: succeededOrFailed()
stages:
- stage: Containerized
jobs:
- job: Build_Test_And_Push_Az_ARO_Extension
pool:
name: 1es-aro-ci-pool
steps:
- template: ./templates/template-checkout.yml

# Build and test the Az ARO Extension
- script: |
set -xe
DOCKER_BUILD_CI_ARGS="--load" make ci-azext-aro VERSION=$(VERSION)
displayName: 🛠 Build & Test Az ARO Extension
# Push the image to ACR
- template: ./templates/template-acr-push.yml
parameters:
acrFQDN: 'arosvcdev.azurecr.io'
repository: 'aro'
repository: 'azext-aro'
pushLatest: true

- job: Lint_Az_ARO_Extension
- job: Build_And_Test_RP_And_Portal
pool:
name: 1es-aro-ci-pool
variables:
HOME: $(Agent.BuildDirectory)
steps:
- template: ./templates/template-checkout.yml

# Build and test RP and Portal
- script: |
set -xe
export AZDEV_CONFIG_DIR=$(Agent.BuildDirectory)/azdev-config
make test-python
[[ -z "$(git status -s)" ]]
target: python
DOCKER_BUILD_CI_ARGS="--load" make ci-rp VERSION=$(VERSION)
displayName: 🛠 Build & Test RP and Portal
# Publish test results
- task: PublishTestResults@2
displayName: 📊 Publish tests results
inputs:
testResultsFiles: $(System.DefaultWorkingDirectory)/report.xml
condition: succeededOrFailed()

# Publish code coverage results
- task: PublishCodeCoverageResults@2
displayName: 📈 Publish code coverage
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/coverage.xml
failIfCoverageEmpty: false
condition: succeededOrFailed()

# Push the image to ACR
- template: ./templates/template-acr-push.yml
parameters:
acrFQDN: 'arosvcdev.azurecr.io'
repository: 'aro'
pushLatest: true

# New E2E Stage with Docker Compose
- stage: E2E
- stage: E2E # E2E Stage using Docker Compose
dependsOn: Containerized
jobs:
- job: Run_E2E_Tests
pool:
name: 1es-aro-ci-pool
steps:
# Checkout the code
# Step 1: Checkout the code
- template: ./templates/template-checkout.yml

# Install Docker Compose and pull the RP image
# Step 2: Pull the RP image from ACR
- template: ./templates/e2e-pipeline-template.yml
parameters:
rpImageACR: 'arosvcdev.azurecr.io'
acrCredentialsJSON: $(acr-credentials)

# Install OpenVPN (the command will depend on the agent OS)
# Step 3: Install Docker Compose and Docker
- script: |
set -xe
sudo apt-get update && sudo apt-get install -y openvpn || \
sudo tdnf install -y openvpn || \
sudo yum install -y openvpn
displayName: Install OpenVPN
# AZ CLI Login using the existing secret as in the old pipeline
sudo apt-get update
sudo apt-get install -y docker.io docker-compose-plugin make
sudo apt-get install -y openvpn
sudo systemctl start docker
sudo systemctl enable docker
displayName: Install OpenVPN, Docker, and Docker Compose
# Step 4: AZ CLI Login using the existing secret as in the old pipeline
- template: ./templates/template-az-cli-login.yml
parameters:
azureDevOpsJSONSPN: $(aro-v4-e2e-devops-spn)

# Step 5: Download and extract VPN secrets with `make secrets`
- script: |
set -xe
az account set -s $AZURE_SUBSCRIPTION_ID
# Download secrets tarball containing the VPN certificates and config
az storage blob download --account-name $(SECRET_SA_ACCOUNT_NAME) --container-name secrets --name vpn-secrets.tar.gz --file vpn-secrets.tar.gz
# Extract the secrets tarball
#command to download the secrets tarball and set the environment
SECRET_SA_ACCOUNT_NAME=$(SECRET_SA_ACCOUNT_NAME) make secrets
. secrets/env
sudo mkdir -p /etc/openvpn
sudo tar -xzf vpn-secrets.tar.gz -C /etc/openvpn
ls -R ./secrets
sudo cp ./secrets/* /etc/openvpn
ls -R /etc/openvpn
# Ensure the extracted files contain the required certificates
ls /etc/openvpn
displayName: Download and Extract VPN Secrets
displayName: Download and Setup VPN Secrets
# Setup Azure and source secrets/env
# Step 6: Setup environment variables for Docker Compose
- script: |
set -xe
export RP_IMAGE_ACR=arosvcdev.azurecr.io
export VERSION=${BUILD_BUILDID}
export E2E_FLAGS="--flag1 --flag2"
export E2E_LABEL="test-label"
export E2E_DELETE_CLUSTER="false"
echo "RP_IMAGE_ACR=$RP_IMAGE_ACR" > .env
echo "VERSION=$VERSION" >> .env
echo "E2E_FLAGS=$E2E_FLAGS" >> .env
echo "E2E_LABEL=$E2E_LABEL" >> .env
. secrets/env
cat .env
sudo openvpn --config /etc/openvpn/vpn.conf &
docker-compose --env-file .env -f docker-compose.yml up -d
displayName: Start OpenVPN and Run Docker Compose for E2E Services
displayName: Set Up Environment Variables
# Log the output from the e2e container in case of failure
# Step 7: Start services using Docker Compose
- script: |
set -xe
docker-compose logs e2e
displayName: Log E2E Test Output
docker compose --env-file .env -f docker-compose.yml up -d
docker ps
displayName: Start Services using Docker Compose
# Step 8: Execute E2E tests
- script: |
docker compose exec e2e-container make test-e2e
displayName: Execute E2E Tests
# Step 9: Log the output from the services in case of failure
- script: |
docker compose logs vpn
docker compose logs selenium
docker compose logs rp
docker compose logs e2e
displayName: Log Service Output
condition: failed()
# Clean up Docker Compose
# Step 10: Clean up Docker Compose services
- script: |
docker-compose down
displayName: Cleanup Docker Compose
docker compose down
displayName: Cleanup Docker Compose Services
condition: always()
# Step 11: Cleanup Azure resources
- script: |
export CI=true
. ./hack/e2e/run-rp-and-e2e.sh
clean_e2e_db
displayName: Cleanup (Azure)
condition: always()
# Step 12: AZ CLI Logout
- template: ./templates/template-az-cli-logout.yml
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ LOCAL_ARO_PORTAL_BUILD_IMAGE ?= $(LOCAL_ARO_RP_IMAGE)-portal-build
LOCAL_ARO_RP_BUILD_IMAGE ?= $(LOCAL_ARO_RP_IMAGE)-build
LOCAL_AZ_EXT_ARO_IMAGE ?= azext-aro
LOCAL_TUNNEL_IMAGE ?= aro-tunnel
LOCAL_VPN_IMAGE ?= vpn_image

###############################################################################
# Targets
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ services:
container_name: aro-portal
depends_on:
rp:
condition: service_healthy
condition: service_started
environment:
- RP_MODE
- AZURE_SUBSCRIPTION_ID
Expand Down

0 comments on commit 018d0c2

Please sign in to comment.