diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8295c5f242811d8e434a5434c84b6f4b0ecaf608..51a76e45336ec53996ad2ef5cca9082a33d93490 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ bootstrap: script: - apk update - apk add ansible musl-dev linux-headers gcc py3-psutil openssh-client moreutils - - pip3 install ansible-runner requests + - pip3 install ansible-runner requests tabulate - cd test - eval $(ssh-agent -s) - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null diff --git a/test/ci-bootstrap.py b/test/ci-bootstrap.py index 9a4f263dedf5b90f847415bfbc5c7b2b2ad54e1a..d8b6740e931a12706bb630065808898d3c161382 100755 --- a/test/ci-bootstrap.py +++ b/test/ci-bootstrap.py @@ -91,6 +91,9 @@ if __name__ == "__main__": ip = droplet['networks']['v4'][0]['ip_address'] name = droplet['name'] + # Create domain record + cosmos.list_domain_records('openappstack.net') + # Wait for ssh cosmos.wait_for_ssh(ip) diff --git a/test/cosmos.py b/test/cosmos.py index e9e78ba786422488dd1b44b509c847dc2cc3f052..75114d5ffd5db17035b6bd09ba82787ab79c5780 100755 --- a/test/cosmos.py +++ b/test/cosmos.py @@ -49,18 +49,19 @@ def request_api(resource: str, request_type: str = 'GET', # API calls -def get_domain_record(domain: str, id: int): - """Get details for given domain record.""" - response = request_api('domains/' + domain + '/records/' + str(id)) +def create_domain_record(domain: str, name: str, data: str, + record_type: str = 'A'): + """Create domain record.""" + print('Creating domain record') + record = { + 'name': name, + 'data': data, + 'type': record_type + } + response = request_api('domains/' + domain + '/records/', 'POST', record) return response['domain_record'] -def get_domain_records(domain: str): - """Get domain records for given domain.""" - response = request_api('domains/' + domain + '/records') - return response['domain_records'] - - def create_droplet(name: str, ssh_key_id: int, region: str = 'ams1', size: int = 2048, disk: int = 20, image: int = 7): """Create a droplet.""" @@ -86,6 +87,18 @@ def delete_droplet(id: int): return response +def get_domain_record(domain: str, id: int): + """Get details for given domain record.""" + response = request_api('domains/' + domain + '/records/' + str(id)) + return response['domain_record'] + + +def get_domain_records(domain: str): + """Get domain records for given domain.""" + response = request_api('domains/' + domain + '/records') + return response['domain_records'] + + def get_droplets(): """Get all information about all droplets.""" response = request_api('droplets')