diff --git a/.github/workflows/test_nets_integration.yml b/.github/workflows/test_nets_integration.yml new file mode 100644 index 000000000..079c9b1e7 --- /dev/null +++ b/.github/workflows/test_nets_integration.yml @@ -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 }} diff --git a/.github/workflows/test_others_integration.yml b/.github/workflows/test_others_integration.yml new file mode 100644 index 000000000..17a40de2a --- /dev/null +++ b/.github/workflows/test_others_integration.yml @@ -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 }} diff --git a/.github/workflows/test_vms_integration.yml b/.github/workflows/test_vms_integration.yml new file mode 100644 index 000000000..f76fb7ea8 --- /dev/null +++ b/.github/workflows/test_vms_integration.yml @@ -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 }} diff --git a/GNUmakefile b/GNUmakefile index a412e6dac..eddfc63a4 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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))) diff --git a/scripts/test_nets_integration.sh b/scripts/test_nets_integration.sh new file mode 100755 index 000000000..f1d34a82d --- /dev/null +++ b/scripts/test_nets_integration.sh @@ -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 diff --git a/scripts/test_others_integration.sh b/scripts/test_others_integration.sh new file mode 100755 index 000000000..42b30595f --- /dev/null +++ b/scripts/test_others_integration.sh @@ -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 diff --git a/scripts/test_vms_integration.sh b/scripts/test_vms_integration.sh new file mode 100755 index 000000000..ea79b12a1 --- /dev/null +++ b/scripts/test_vms_integration.sh @@ -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