diff --git a/.gitlab-ci.jsonnet b/.gitlab-ci.jsonnet index 136ba2d6d..e39933e8f 100644 --- a/.gitlab-ci.jsonnet +++ b/.gitlab-ci.jsonnet @@ -9,7 +9,7 @@ local stages_list = [ 'docker_base', 'docker_build', 'deploy_preview', - 'unit_tests', + 'tests', 'integration', 'docker_release', 'deploy_staging', @@ -24,12 +24,13 @@ local jobs = { local onlyMaster = { only: ['master', 'tags'], }, + local onlyBranch = { only: ['branches'], except: ['master'] }, - 'container-base-build': baseJob.dockerBuild + onlyMaster { + 'container-base-build': baseJob.dockerBuild { // ! Only master/tags // Update the base container stage: stages.docker_base, @@ -38,6 +39,7 @@ local jobs = { ' -t %s -f quay-base.dockerfile .' % images.base.name, 'docker push %s' % images.base.name, ], + only: ["schedules"] }, 'container-build': baseJob.dockerBuild { @@ -67,7 +69,7 @@ local jobs = { // Unit-tests local unittest_stage = baseJob.QuayTest { - stage: stages.unit_tests }, + stage: stages.tests }, local pytest_cmd = 'py.test --cov="." --cov-report=html --cov-report=term-missing' + ' --timeout=3600 --verbose -x --color=no --show-count ', 'unit-tests': unittest_stage { @@ -97,8 +99,59 @@ local jobs = { 'yarn test' ] }, + // Integration API + local integration_test = baseJob.EndToEndTest { + stage: stages.integration + }, + + 'protractor_e2e': integration_test { + initDb:: true, + variables+: {"APP_HOST": "http://localhost:80"}, + services+: [{name: "selenium/standalone-chrome:3.4.0"}], + before_script+: [ + "curl -sL https://deb.nodesource.com/setup_8.x | bash -", + "apt-get install -y nodejs", + "./node_modules/.bin/webdriver-manager update", + ], + allow_failure: true, + script+: [ + "yarn e2e", + ] + }, + + 'appr_e2e': integration_test { + initDb:: true, + image: {name: "quay.io/appr/appr:kubectl"}, + before_script: [], + script+: [ + "appr version localhost:80", + "appr list localhost:80", + ], + allow_failure: true, + }, + + 'docker_e2e': integration_test { + initDb:: true, + image: {name: "docker"}, + services+: [{name: "docker:dind"}], + variables+: { + DOCKER_DRIVER: "overlay2", + DOCKER_HOST: "tcp://localhost:2375" + }, + before_script: [], + script+: [ + "docker login localhost:80 -u devtable -p password", + "docker pull nginx", + "docker tag nginx localhost:80/devtable/nginx", + "docker push localhost:80/devtable/nginx", + "sleep 1", + "docker pull localhost:80/devtable/nginx", + ], + allow_failure: true, + }, + // Unit-tests with real databases - local db_stage = { stage: stages.unit_tests }, + local db_stage = { stage: stages.tests }, local dbname = 'quay', postgres: db_stage + baseJob.dbTest('postgresql', diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b235a8613..18f69eb0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,46 @@ # Generated from .gitlab-ci.jsonnet # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN --- +appr_e2e: + allow_failure: true + before_script: [] + image: + name: quay.io/appr/appr:kubectl + script: + - sleep 150 + - appr version localhost:80 + - appr list localhost:80 + services: + - name: postgres:9.6 + - alias: quay + name: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} + - alias: db-init + command: + - /bin/sh + - -c + - sleep 30&& /quay-registry/venv/bin/python initdb.py&& sleep 3600 + name: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} + stage: integration + tags: + - kubernetes + variables: + APP_HOST: localhost:80 + DB_URI: postgresql://quay:quay@localhost/quay + GIT_STRATEGY: none + POSTGRES_PASSWORD: quay + POSTGRES_USER: quay + PYTHONPATH: . + QUAYDIR: /quay-registry + QUAY_OVERRIDE_CONFIG: '{"SERVER_HOSTNAME": "localhost:80"}' + SKIP_DB_SCHEMA: 'true' + TEST: 'true' + TEST_DATABASE_URI: postgresql://quay:quay@localhost/quay container-base-build: before_script: - docker login -u $DOCKER_USER -p $DOCKER_PASS quay.io image: docker:git only: - - master - - tags + - schedules script: - docker build --no-cache -t quay.io/quay/quay-base:latest -f quay-base.dockerfile . - docker push quay.io/quay/quay-base:latest @@ -15,7 +48,7 @@ container-base-build: tags: - kubernetes variables: - DOCKER_DRIVER: overlay + DOCKER_DRIVER: overlay2 DOCKER_HOST: tcp://docker-host.gitlab-runner.svc.cluster.local:2375 container-build: before_script: @@ -32,7 +65,7 @@ container-build: tags: - kubernetes variables: - DOCKER_DRIVER: overlay + DOCKER_DRIVER: overlay2 DOCKER_HOST: tcp://docker-host.gitlab-runner.svc.cluster.local:2375 container-release: before_script: @@ -49,7 +82,7 @@ container-release: tags: - kubernetes variables: - DOCKER_DRIVER: overlay + DOCKER_DRIVER: overlay2 DOCKER_HOST: tcp://docker-host.gitlab-runner.svc.cluster.local:2375 deploy-preview: before_script: @@ -104,6 +137,47 @@ deploy-staging: variables: K8S_NAMESPACE: ci-staging QUAY_DOMAIN: quay-staging.k8s.devtable.com +docker_e2e: + allow_failure: true + before_script: [] + image: + name: docker + script: + - sleep 150 + - docker login localhost:80 -u devtable -p password + - docker pull nginx + - docker tag nginx localhost:80/devtable/nginx + - docker push localhost:80/devtable/nginx + - sleep 1 + - docker pull localhost:80/devtable/nginx + services: + - name: postgres:9.6 + - alias: quay + name: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} + - alias: db-init + command: + - /bin/sh + - -c + - sleep 30&& /quay-registry/venv/bin/python initdb.py&& sleep 3600 + name: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} + - name: docker:dind + stage: integration + tags: + - kubernetes + variables: + APP_HOST: localhost:80 + DB_URI: postgresql://quay:quay@localhost/quay + DOCKER_DRIVER: overlay2 + DOCKER_HOST: tcp://localhost:2375 + GIT_STRATEGY: none + POSTGRES_PASSWORD: quay + POSTGRES_USER: quay + PYTHONPATH: . + QUAYDIR: /quay-registry + QUAY_OVERRIDE_CONFIG: '{"SERVER_HOSTNAME": "localhost:80"}' + SKIP_DB_SCHEMA: 'true' + TEST: 'true' + TEST_DATABASE_URI: postgresql://quay:quay@localhost/quay karma-tests: before_script: - cd $QUAYDIR @@ -115,7 +189,7 @@ karma-tests: - apt-get update -yqqq - apt-get install -y google-chrome-stable - yarn test - stage: unit_tests + stage: tests tags: - kubernetes variables: @@ -135,7 +209,7 @@ mysql: - PYTHONPATH="." TEST="true" py.test --timeout=7200 --verbose --show-count ./ --color=no --ignore=endpoints/appr/test/ -x services: - mysql:latest - stage: unit_tests + stage: tests tags: - kubernetes variables: @@ -161,7 +235,7 @@ postgres: - PYTHONPATH="." TEST="true" py.test --timeout=7200 --verbose --show-count ./ --color=no --ignore=endpoints/appr/test/ -x services: - postgres:9.6 - stage: unit_tests + stage: tests tags: - kubernetes variables: @@ -173,6 +247,44 @@ postgres: SKIP_DB_SCHEMA: 'true' TEST: 'true' TEST_DATABASE_URI: postgresql://quay:quay@localhost/quay +protractor_e2e: + allow_failure: true + before_script: + - cd $QUAYDIR + - source $QUAYDIR/venv/bin/activate + - curl -sL https://deb.nodesource.com/setup_8.x | bash - + - apt-get install -y nodejs + - ./node_modules/.bin/webdriver-manager update + image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} + script: + - sleep 150 + - yarn e2e + services: + - name: postgres:9.6 + - alias: quay + name: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} + - alias: db-init + command: + - /bin/sh + - -c + - sleep 30&& /quay-registry/venv/bin/python initdb.py&& sleep 3600 + name: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} + - name: selenium/standalone-chrome:3.4.0 + stage: integration + tags: + - kubernetes + variables: + APP_HOST: http://localhost:80 + DB_URI: postgresql://quay:quay@localhost/quay + GIT_STRATEGY: none + POSTGRES_PASSWORD: quay + POSTGRES_USER: quay + PYTHONPATH: . + QUAYDIR: /quay-registry + QUAY_OVERRIDE_CONFIG: '{"SERVER_HOSTNAME": "localhost:80"}' + SKIP_DB_SCHEMA: 'true' + TEST: 'true' + TEST_DATABASE_URI: postgresql://quay:quay@localhost/quay registry-tests: before_script: - cd $QUAYDIR @@ -181,7 +293,7 @@ registry-tests: image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} script: - py.test --cov="." --cov-report=html --cov-report=term-missing --timeout=3600 --verbose -x --color=no --show-count ./test/registry_tests.py - stage: unit_tests + stage: tests tags: - kubernetes variables: @@ -193,7 +305,7 @@ stages: - docker_base - docker_build - deploy_preview -- unit_tests +- tests - integration - docker_release - deploy_staging @@ -233,7 +345,7 @@ unit-tests: image: quay.io/quay/quay-ci:${CI_COMMIT_REF_SLUG} script: - py.test --cov="." --cov-report=html --cov-report=term-missing --timeout=3600 --verbose -x --color=no --show-count ./ - stage: unit_tests + stage: tests tags: - kubernetes variables: diff --git a/.gitlab-ci/base_jobs.libsonnet b/.gitlab-ci/base_jobs.libsonnet index 2fee90d51..a65ef9c8d 100644 --- a/.gitlab-ci/base_jobs.libsonnet +++ b/.gitlab-ci/base_jobs.libsonnet @@ -3,7 +3,7 @@ function(vars={}) dockerBuild: { // base job to manage containers (build / push) variables: { - DOCKER_DRIVER: "overlay", + DOCKER_DRIVER: "overlay2", DOCKER_HOST: "tcp://docker-host.gitlab-runner.svc.cluster.local:2375" }, @@ -35,7 +35,6 @@ function(vars={}) ], }, - QuayDeploy: { local this = self, local _vars = self.localvars, @@ -99,6 +98,35 @@ function(vars={}) }, before_script: [], script: [], + }, + + EndToEndTest: self.QuayTest { + initDb:: true, + services: [ + {name: "postgres:9.6"}, + {name: vars.images.quayci.name, alias: 'quay'} + ] + if self.initDb == true then [ + {name: vars.images.quayci.name, + alias: 'db-init', + command: ["/bin/sh", + "-c", + "sleep 30" + + "&& /quay-registry/venv/bin/python initdb.py" + + "&& sleep 3600",]}, + ] else [], + before_script: if self.image == vars.images.quayci.name + then super.before_script + else [], + script: ['sleep 150'], + variables+: { + APP_HOST: "localhost:80", + POSTGRES_PASSWORD: "quay", + POSTGRES_USER: "quay", + SKIP_DB_SCHEMA: 'true', + TEST_DATABASE_URI: self['DB_URI'], + QUAY_OVERRIDE_CONFIG: '' + {"SERVER_HOSTNAME": "localhost:80"}, + DB_URI: 'postgresql://quay:quay@localhost/quay' + }, }, dbTest(scheme, image, env):: self.QuayTest { diff --git a/quay-base.dockerfile b/quay-base.dockerfile index 996469cde..3d3c1240b 100644 --- a/quay-base.dockerfile +++ b/quay-base.dockerfile @@ -18,7 +18,7 @@ RUN add-apt-repository ppa:nginx/development # Add Yarn repository until it is officially added to Ubuntu RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - +RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - # Install system packages RUN apt-get update && apt-get upgrade -y \ && apt-get install -y \ diff --git a/static/test/protractor.conf.ts b/static/test/protractor.conf.ts index e69f9753d..864b37642 100644 --- a/static/test/protractor.conf.ts +++ b/static/test/protractor.conf.ts @@ -20,7 +20,7 @@ export const config: Config = { framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', // Uncomment to run tests against local Chrome instance - directConnect: true, + // directConnect: true, capabilities: { browserName: 'chrome', chromeOptions: {