Use upstream TF test repo (#4163)

This commit is contained in:
Bert Blommers 2021-08-12 16:55:53 +01:00 committed by GitHub
parent b3fe48ece0
commit 67199d9828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 10 deletions

View File

@ -15,7 +15,8 @@ jobs:
- name: Checkout Terraform Tests repo - name: Checkout Terraform Tests repo
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
repository: bblommers/moto-terraform-tests repository: localstack/localstack-terraform-test
ref: build
path: moto-terraform-tests path: moto-terraform-tests
submodules: 'true' submodules: 'true'
- uses: actions/setup-go@v2 - uses: actions/setup-go@v2
@ -27,8 +28,10 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: '~/.cache' path: '~/.cache'
key: 'terraformcache' key: 'terraformcache3'
- name: Download - name: Download
env:
DOWNLOAD_TEST_BIN: 1
if: ${{ steps.terraformcache.outputs.cache-hit != 'true' }} if: ${{ steps.terraformcache.outputs.cache-hit != 'true' }}
run: | run: |
cd moto-terraform-tests cd moto-terraform-tests
@ -210,7 +213,8 @@ jobs:
- name: Checkout Terraform Tests repo - name: Checkout Terraform Tests repo
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
repository: bblommers/moto-terraform-tests repository: localstack/localstack-terraform-test
ref: build
path: moto-terraform-tests path: moto-terraform-tests
submodules: 'true' submodules: 'true'
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
@ -221,16 +225,16 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: '~/.cache' path: '~/.cache'
key: 'terraformcache' key: 'terraformcache3'
- name: Start MotoServer - name: Start MotoServer
run: | run: |
python setup.py sdist python setup.py sdist
docker run --rm -t --name motoserver -e TEST_SERVER_MODE=true -e AWS_SECRET_ACCESS_KEY=server_secret -e AWS_ACCESS_KEY_ID=server_key -v `pwd`:/moto -p 5000:5000 -v /var/run/docker.sock:/var/run/docker.sock python:3.7-buster /moto/travis_moto_server.sh & docker run --rm -t --name motoserver -e TEST_SERVER_MODE=true -e MOTO_PORT=4566 -e AWS_SECRET_ACCESS_KEY=server_secret -e AWS_ACCESS_KEY_ID=server_key -v `pwd`:/moto -p 4566:4566 -v /var/run/docker.sock:/var/run/docker.sock python:3.7-buster /moto/travis_moto_server.sh &
python wait_for.py MOTO_PORT=4566 python wait_for.py
- name: Run Terraform Tests - name: Run Terraform Tests
run: | run: |
cd moto-terraform-tests cd moto-terraform-tests
AWS_DEFAULT_REGION=us-east-1 AWS_ALTERNATE_REGION=eu-west-1 bin/run-tests -i ../tests/terraform-tests.success.txt -e ../tests/terraform-tests.failures.txt AWS_DEFAULT_REGION=us-east-1 AWS_ALTERNATE_REGION=eu-west-1 bin/run-tests -t -i ../tests/terraform-tests.success.txt -e ../tests/terraform-tests.failures.txt
cd .. cd ..
- name: "Create report" - name: "Create report"
run: | run: |
@ -238,6 +242,12 @@ jobs:
bin/create-report bin/create-report
bin/create-report-cli bin/create-report-cli
cd .. cd ..
- name: Archive TF logs
uses: actions/upload-artifact@v2
with:
name: buildfolder
path: |
moto-terraform-tests/build/*
deploy: deploy:
name: Deploy name: Deploy

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
export MOTO_PORT=${MOTO_PORT:-5000}
set -e set -e
pip install $(ls /moto/dist/moto*.gz)[server,all] pip install $(ls /moto/dist/moto*.gz)[server,all]
moto_server -H 0.0.0.0 -p 5000 moto_server -H 0.0.0.0 -p ${MOTO_PORT}

View File

@ -1,3 +1,4 @@
import os
import time import time
try: try:
@ -18,10 +19,13 @@ except ImportError:
start_ts = time.time() start_ts = time.time()
print("Waiting for service to come up") expected_port = os.environ.get("MOTO_PORT", "5000")
expected_host = "http://localhost:{}/".format(expected_port)
print("Waiting for service to come up on {}".format(expected_host))
while True: while True:
try: try:
urllib.urlopen("http://localhost:5000/", timeout=1)
urllib.urlopen(expected_host, timeout=1)
break break
except EXCEPTIONS: except EXCEPTIONS:
elapsed_s = time.time() - start_ts elapsed_s = time.time() - start_ts