From 2f77c67a62cb0cf9b10a19841891460b7378f59d Mon Sep 17 00:00:00 2001 From: Shane McDonald Date: Tue, 21 May 2019 19:15:21 -0400 Subject: [PATCH] Changes to enable tests in k8s --- Makefile | 12 +-- .../tests/functional/api/test_settings.py | 10 --- tools/docker-compose/Dockerfile | 26 +++++- tools/docker-compose/start_tests.sh | 6 -- tox.ini | 82 ------------------- 5 files changed, 29 insertions(+), 107 deletions(-) delete mode 100644 tox.ini diff --git a/Makefile b/Makefile index b460aa5116..d38d7e444f 100644 --- a/Makefile +++ b/Makefile @@ -346,6 +346,7 @@ pylint: reports genschema: reports $(MAKE) swagger PYTEST_ARGS="--genschema" + mv swagger.json schema.json swagger: reports @if [ "$(VENV_BASE)" ]; then \ @@ -496,6 +497,10 @@ ui-devel: $(UI_DEPS_FLAG_FILE) ui-test: $(UI_DEPS_FLAG_FILE) $(NPM_BIN) --prefix awx/ui run test +ui-lint: $(UI_DEPS_FLAG_FILE) + $(NPM_BIN) run --prefix awx/ui jshint + $(NPM_BIN) run --prefix awx/ui lint + # A standard go-to target for API developers to use building the frontend ui: clean-ui ui-devel @@ -572,12 +577,7 @@ docker-compose-runtest: docker-compose-build-swagger: cd tools && CURRENT_UID=$(shell id -u) TAG=$(COMPOSE_TAG) DEV_DOCKER_TAG_BASE=$(DEV_DOCKER_TAG_BASE) docker-compose run --rm --service-ports awx /start_tests.sh swagger -docker-compose-genschema: - cd tools && CURRENT_UID=$(shell id -u) TAG=$(COMPOSE_TAG) DEV_DOCKER_TAG_BASE=$(DEV_DOCKER_TAG_BASE) docker-compose run --rm --service-ports awx /start_tests.sh genschema - mv swagger.json schema.json - -docker-compose-detect-schema-change: - $(MAKE) docker-compose-genschema +detect-schema-change: genschema curl https://s3.amazonaws.com/awx-public-ci-files/schema.json -o reference-schema.json # Ignore differences in whitespace with -b diff -u -b reference-schema.json schema.json diff --git a/awx/main/tests/functional/api/test_settings.py b/awx/main/tests/functional/api/test_settings.py index de38f3ce54..03d7620883 100644 --- a/awx/main/tests/functional/api/test_settings.py +++ b/awx/main/tests/functional/api/test_settings.py @@ -386,16 +386,6 @@ def test_saml_x509cert_validation(patch, get, admin, headers): assert resp.status_code == 200 -@pytest.mark.django_db -def test_default_broker_url(): - url = parse_url(settings.BROKER_URL) - assert url['transport'] == 'amqp' - assert url['hostname'] == 'rabbitmq' - assert url['userid'] == 'guest' - assert url['password'] == 'guest' - assert url['virtual_host'] == '/' - - @pytest.mark.django_db def test_broker_url_with_special_characters(): settings.BROKER_URL = 'amqp://guest:a@ns:ibl3#@rabbitmq:5672//' diff --git a/tools/docker-compose/Dockerfile b/tools/docker-compose/Dockerfile index cf36c8545e..f760005f62 100644 --- a/tools/docker-compose/Dockerfile +++ b/tools/docker-compose/Dockerfile @@ -6,14 +6,20 @@ RUN yum -y update && yum -y install epel-release # sync with installer/roles/image_build/templates/Dockerfile.j2 RUN yum -y install acl \ + alsa-lib \ ansible \ + atk \ bubblewrap \ + cups-libs \ curl \ cyrus-sasl \ cyrus-sasl-devel \ gcc \ gcc-c++ \ + GConf2 \ git \ + gtk3 \ + ipa-gothic-fonts \ krb5-devel \ krb5-libs \ krb5-workstation \ @@ -22,8 +28,16 @@ RUN yum -y install acl \ libselinux-python \ libstdc++.so.6 \ libtool-ltdl-devel \ + libXcomposite \ + libXcursor \ + libXdamage \ + libXext \ + libXi \ libxml2-devel \ + libXrandr \ + libXScrnSaver \ libxslt-devel \ + libXtst \ make \ mercurial \ mg \ @@ -34,7 +48,6 @@ RUN yum -y install acl \ postgresql-devel \ python-devel \ python-pip \ - python-pip \ python-psutil \ python-psycopg2 \ python-setuptools \ @@ -52,6 +65,12 @@ RUN yum -y install acl \ xmlsec1-devel \ xmlsec1-openssl \ xmlsec1-openssl-devel \ + xorg-x11-fonts-100dpi \ + xorg-x11-fonts-75dpi \ + xorg-x11-fonts-cyrillic \ + xorg-x11-fonts-misc \ + xorg-x11-fonts-Type1 \ + xorg-x11-utils \ yum-utils ADD https://github.com/krallin/tini/releases/download/v0.14.0/tini /tini @@ -67,7 +86,7 @@ ADD tools/docker-compose/awx.egg-info /tmp/awx.egg-info RUN openssl req -nodes -newkey rsa:2048 -keyout /etc/nginx/nginx.key -out /etc/nginx/nginx.csr -subj "/C=US/ST=North Carolina/L=Durham/O=Ansible/OU=AWX Development/CN=awx.localhost" RUN openssl x509 -req -days 365 -in /etc/nginx/nginx.csr -signkey /etc/nginx/nginx.key -out /etc/nginx/nginx.crt -RUN python3 -m ensurepip && pip3 install virtualenv +RUN python3 -m ensurepip && pip3 install virtualenv flake8 RUN pip install supervisor ADD Makefile /tmp/Makefile @@ -86,7 +105,6 @@ RUN cd /tmp && VENV_BASE="/venv" make requirements_dev # Use the distro provided npm to bootstrap our required version of node RUN npm install -g n RUN n 8.15.0 -ENV PATH /usr/bin:/usr/local/n/versions/node/8.15.0/bin:$PATH RUN yum -y remove cyrus-sasl-devel \ gcc \ @@ -131,3 +149,5 @@ RUN for dir in /var/lib/awx/ /var/log/tower/ /projects /.ansible /var/log/nginx RUN for file in /etc/passwd /etc/supervisord.conf \ /venv/awx/lib/python3.6/site-packages/awx.egg-link /var/run/nginx.pid; \ do touch $file; chmod -R g+rwx $file; chgrp -R root $file; done + +ENV PATH=/usr/local/n/versions/node/8.15.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin diff --git a/tools/docker-compose/start_tests.sh b/tools/docker-compose/start_tests.sh index 972de85b1d..a33d9a672f 100755 --- a/tools/docker-compose/start_tests.sh +++ b/tools/docker-compose/start_tests.sh @@ -1,12 +1,6 @@ #!/bin/bash set +x -if [ `id -u` -ge 500 ] || [ -z "${CURRENT_UID}" ]; then - echo "awx:x:`id -u`:`id -g`:,,,:/tmp:/bin/bash" >> /tmp/passwd - cat /tmp/passwd > /etc/passwd - rm /tmp/passwd -fi - cd /awx_devel make clean cp -R /tmp/awx.egg-info /awx_devel/ || true diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 39596025b0..0000000000 --- a/tox.ini +++ /dev/null @@ -1,82 +0,0 @@ -[tox] -skipsdist = true -envlist = - api-lint, - ui-lint, - api, - ui, - swagger, - detect-schema-change, - -[testenv] -;basepython = python2.7 -whitelist_externals = make -; setenv = -; DJANGO_SETTINGS_MODULE = awx.settings.development_quiet -; SWIG_FEATURES = -cpperraswarn -includeall -I/usr/include/openssl -; HOME = {homedir} -; USERPROFILE = {homedir} -; ANSIBLE_VENV_PATH = {toxworkdir} -; AWX_VENV_PATH = {toxworkdir} -; SKIP_SLOW_TESTS = True - -[testenv:api-lint] -basepython = python3.6 -deps = - -r{toxinidir}/requirements/requirements_dev.txt - coverage - coveralls -commands = - flake8 - -[testenv:ui-lint] -deps = - nodeenv -commands = - make clean-ui - make ui-devel - npm run --prefix awx/ui jshint - npm run --prefix awx/ui lint - -[testenv:api] -deps = - #-r{toxinidir}/requirements/requirements.txt - #-r{toxinidir}/requirements/requirements_git.txt - #-r{toxinidir}/requirements/requirements_dev.txt - #ansible - #coverage - #coveralls -; https://github.com/docker/compose/issues/6311 - docker-compose<1.23.0 -commands = - #python setup.py develop - # coverage run --help - # coverage run -p --source awx/main/tests -m pytest {posargs} - #py.test -n auto awx/main/tests/unit awx/main/tests/functional awx/conf/tests awx/sso/tests - #awx-manage check_migrations --dry-run --check -n 'vNNN_missing_migration_file' - #make test - make docker-compose-build - make docker-compose-runtest - -[testenv:ui] -deps = - nodeenv -commands = - make clean-ui - make ui-devel - make ui-test-ci - - -[testenv:swagger] -deps = - nodeenv -commands = - make docker-compose-build - make docker-compose-build-swagger - -[testenv:detect-schema-change] -deps = - nodeenv -commands = - make docker-compose-build - make docker-compose-detect-schema-change