Skip to content

Commit

Permalink
split integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-toa committed Mar 31, 2023
1 parent 80d0d7d commit 4e93aa4
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/test_nets_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Nets integration tests

on:
pull_request:
branches:
- master
paths:
- '**.go'
- 'tests/**'
- 'scripts/test_nets_integration.sh'
- 'GNUmakefile'
- '!**_test.go'
workflow_dispatch:

jobs:
Nets_integration_tests:
environment: test-eu-west-2
runs-on: [self-hosted, linux, eu-west-2]
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: outscale-dev/frieza-github-actions/frieza-clean@master
with:
access_key: ${{ secrets.OSC_ACCESS_KEY }}
secret_key: ${{ secrets.OSC_SECRET_KEY }}
region: ${{ secrets.OSC_REGION }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.5.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.5
terraform_wrapper: false
- name: Run nets integration tests
run: make test-nets-integration
env:
OUTSCALE_ACCESSKEYID: ${{ secrets.OSC_ACCESS_KEY }}
OUTSCALE_SECRETKEYID: ${{ secrets.OSC_SECRET_KEY }}
OUTSCALE_REGION: ${{ secrets.OSC_REGION }}
OUTSCALE_ACCOUNT: ${{ secrets.OSC_ACCOUNT_ID }}
OUTSCALE_IMAGEID: ${{ secrets.OUTSCALE_IMAGEID }}
52 changes: 52 additions & 0 deletions .github/workflows/test_others_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Others integration tests

on:
pull_request:
branches:
- master
paths:
- '**.go'
- 'tests/**'
- 'scripts/test_others_integration.sh'
- 'GNUmakefile'
- '!**_test.go'
workflow_dispatch:

jobs:
Others_integration_tests:
environment: test-eu-west-2
runs-on: [self-hosted, linux, eu-west-2]
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: outscale-dev/frieza-github-actions/frieza-clean@master
with:
access_key: ${{ secrets.OSC_ACCESS_KEY }}
secret_key: ${{ secrets.OSC_SECRET_KEY }}
region: ${{ secrets.OSC_REGION }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.5.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.5
terraform_wrapper: false
- name: Run others integration tests
run: make test-others-integration
env:
OUTSCALE_ACCESSKEYID: ${{ secrets.OSC_ACCESS_KEY }}
OUTSCALE_SECRETKEYID: ${{ secrets.OSC_SECRET_KEY }}
OUTSCALE_REGION: ${{ secrets.OSC_REGION }}
OUTSCALE_ACCOUNT: ${{ secrets.OSC_ACCOUNT_ID }}
OUTSCALE_IMAGEID: ${{ secrets.OUTSCALE_IMAGEID }}
52 changes: 52 additions & 0 deletions .github/workflows/test_vms_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Vms integration tests

on:
pull_request:
branches:
- master
paths:
- '**.go'
- 'tests/**'
- 'scripts/test_vms_integration.sh'
- 'GNUmakefile'
- '!**_test.go'
workflow_dispatch:

jobs:
Vms_integration_tests:
environment: test-eu-west-2
runs-on: [self-hosted, linux, eu-west-2]
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: outscale-dev/frieza-github-actions/frieza-clean@master
with:
access_key: ${{ secrets.OSC_ACCESS_KEY }}
secret_key: ${{ secrets.OSC_SECRET_KEY }}
region: ${{ secrets.OSC_REGION }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '>=1.18.0'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.5.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.5
terraform_wrapper: false
- name: Run vms integration tests
run: make test-vms-integration
env:
OUTSCALE_ACCESSKEYID: ${{ secrets.OSC_ACCESS_KEY }}
OUTSCALE_SECRETKEYID: ${{ secrets.OSC_SECRET_KEY }}
OUTSCALE_REGION: ${{ secrets.OSC_REGION }}
OUTSCALE_ACCOUNT: ${{ secrets.OSC_ACCOUNT_ID }}
OUTSCALE_IMAGEID: ${{ secrets.OUTSCALE_IMAGEID }}
12 changes: 12 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ test-examples:
test-integration:
@sh -c "'$(CURDIR)/scripts/integration.sh'"

.PHONY: test-vms-integration
test-vms-integration:
@sh -c "'$(CURDIR)/scripts/test_vms_integration.sh'"

.PHONY: test-nets-integration
test-nets-integration:
@sh -c "'$(CURDIR)/scripts/test_nets_integration.sh'"

.PHONY: test-others-integration
test-others-integration:
@sh -c "'$(CURDIR)/scripts/test_others_integration.sh'"

.PHONY: website
website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
Expand Down
27 changes: 27 additions & 0 deletions scripts/test_nets_integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -e

project_dir=$(cd "$(dirname $0)" && pwd)
project_root=$(cd $project_dir/.. && pwd)
BUILD_DIR=$project_root/tests/qa_provider_oapi

python3 --version || (echo "We need 'python3' intalled to run integration tests"; exit 1)
python3 -m venv .venv
source .venv/bin/activate
pip --version || (echo "We need 'pip' intalled to run integration tests"; exit 1)

make fmt
make test
go build -o terraform-provider-outscale_v0.5.32
mkdir -p $BUILD_DIR/terraform.d/plugins/registry.terraform.io/outscale/outscale/0.5.32/linux_amd64/
mv terraform-provider-outscale_v0.5.32 $BUILD_DIR/terraform.d/plugins/registry.terraform.io/outscale/outscale/0.5.32/linux_amd64/

cd $BUILD_DIR
git grep '"outscale_net"' data/ | awk -F/ '{ print $3 }' | awk -F_ '{ print $1 }' | sort | uniq > listNets

pip install -r requirements.txt
while read line; do
pytest -k $line -v ./test_provider_oapi.py
done < listNets

rm -fr terraform.d listNets || exit 0
39 changes: 39 additions & 0 deletions scripts/test_others_integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -e

project_dir=$(cd "$(dirname $0)" && pwd)
project_root=$(cd $project_dir/.. && pwd)
BUILD_DIR=$project_root/tests/qa_provider_oapi

python3 --version || (echo "We need 'python3' intalled to run integration tests"; exit 1)
python3 -m venv .venv
source .venv/bin/activate
pip --version || (echo "We need 'pip' intalled to run integration tests"; exit 1)

make fmt
make test
go build -o terraform-provider-outscale_v0.5.32
mkdir -p $BUILD_DIR/terraform.d/plugins/registry.terraform.io/outscale/outscale/0.5.32/linux_amd64/
mv terraform-provider-outscale_v0.5.32 $BUILD_DIR/terraform.d/plugins/registry.terraform.io/outscale/outscale/0.5.32/linux_amd64/

cd $BUILD_DIR
git grep '"outscale_vm"' data/ | awk -F/ '{ print $3 }' | awk -F_ '{ print $1 }' | sort | uniq > listVms
sed -r -i '/TF-(109|111|113|144|145|65)/d' listVms
git grep '"outscale_net"' data/ | awk -F/ '{ print $3 }' | awk -F_ '{ print $1 }' | sort | uniq > listNets
git grep 'resource "' data/ | awk -F/ '{ print $3 }' | awk -F_ '{ print $1 }' | sort | uniq > listOthres
git grep 'data "' data/ | awk -F/ '{ print $3 }' | awk -F_ '{ print $1 }' | sort | uniq >> listOthres

while read line; do
sed -i "/$line/d" listOthres
done < listVms

while read line; do
sed -i "/$line/d" listOthres
done < listNets

pip install -r requirements.txt
while read line; do
pytest -k $line -v ./test_provider_oapi.py
done < listOthres

rm -fr terraform.d listVms listNets listOthres || exit 0
29 changes: 29 additions & 0 deletions scripts/test_vms_integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -e

project_dir=$(cd "$(dirname $0)" && pwd)
project_root=$(cd $project_dir/.. && pwd)
BUILD_DIR=$project_root/tests/qa_provider_oapi

python3 --version || (echo "We need 'python3' intalled to run integration tests"; exit 1)
python3 -m venv .venv
source .venv/bin/activate
pip --version || (echo "We need 'pip' intalled to run integration tests"; exit 1)

make fmt
make test
go build -o terraform-provider-outscale_v0.5.32
mkdir -p $BUILD_DIR/terraform.d/plugins/registry.terraform.io/outscale/outscale/0.5.32/linux_amd64/
mv terraform-provider-outscale_v0.5.32 $BUILD_DIR/terraform.d/plugins/registry.terraform.io/outscale/outscale/0.5.32/linux_amd64/

cd $BUILD_DIR

git grep '"outscale_vm"' data/ | awk -F/ '{ print $3 }' | awk -F_ '{ print $1 }' | sort | uniq > listVms
sed -r -i '/TF-(109|111|113|144|145|65)/d' listVms

pip install -r requirements.txt
while read line; do
pytest -k $line -v ./test_provider_oapi.py
done < listVms

rm -fr terraform.d listVms || exit 0

0 comments on commit 4e93aa4

Please sign in to comment.