diff --git a/.azure.yml b/.azure.yml deleted file mode 100644 index b82fd74..0000000 --- a/.azure.yml +++ /dev/null @@ -1,8 +0,0 @@ -pool: - vmImage: 'vs2017-win2016' - -steps: -- script: | - docker pull microsoft/windowsservercore - docker-compose --version - displayName: Test diff --git a/.dockerignore b/.dockerignore index 9464c95..adc4c50 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,3 @@ .git/ -.dockerignore/ -django \ No newline at end of file +.dockerignore +output/ diff --git a/.editorconfig b/.editorconfig index 37b4d92..eb54abf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,12 @@ root = true [*] -indent_style = space +charset = utf-8 +end_of_line = lf indent_size = 4 +indent_style = space insert_final_newline = true trim_trailing_whitespace = true -end_of_line = lf -charset = utf-8 -[*.yml] +[*.{yaml,yml}] indent_size = 2 diff --git a/.env b/.env index 9467ae3..e77a955 100644 --- a/.env +++ b/.env @@ -1,6 +1,7 @@ +PYTHON_IMPLEMENTATION=python PYTHON_VERSION=3.10 -POSTGRES_VERSION=13 -POSTGIS_VERSION=3.0 -MYSQL_VERSION=8 MARIADB_VERSION=10.5 -PIP_CACHE_VOLUME=pip-cache +MYSQL_VERSION=8.0 +ORACLE_VERSION=23.5.0.0 +POSTGRESQL_VERSION=14 +POSTGIS_VERSION=3.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..13f8e2c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,40 @@ +--- +name: Lint + +on: # yamllint disable-line rule:truthy + pull_request: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + COLUMNS: '120' + FORCE_COLOR: '1' + +jobs: + pre-commit: + runs-on: ubuntu-latest + name: pre-commit + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + cache: pip + - name: Install packages + run: python -m pip install --upgrade pip pre-commit + - name: Run linting tools + run: pre-commit run --all-files + env: + PRE_COMMIT_COLOR: always diff --git a/.gitignore b/.gitignore index c3eed66..6ee304b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +__pycache__/ .idea/ -oracle/*.zip \ No newline at end of file +.mypy_cache/ +.ruff_cache/ diff --git a/.hadolint.yml b/.hadolint.yml new file mode 100644 index 0000000..1e55b63 --- /dev/null +++ b/.hadolint.yml @@ -0,0 +1,5 @@ +--- +ignored: + - DL3013 # Don't complain when upgrading to latest version of pip + - DL3022 # Due to use of additional_contexts in compose.yaml + - DL3042 # Caching is desired with RUN --mount=type=cache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1aa3f4c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,53 @@ +--- +ci: + autoupdate_schedule: weekly +repos: + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: check-builtin-literals + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + # - id: check-toml + - id: check-vcs-permalinks + - id: check-yaml + - id: debug-statements + - id: detect-private-key + - id: end-of-file-fixer + - id: file-contents-sorter + args: [--unique] + files: ^(?:packages|requirements)\.txt$ + - id: fix-byte-order-marker + - id: fix-encoding-pragma + args: [--remove] + - id: requirements-txt-fixer + - id: trailing-whitespace + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.2 + hooks: + - id: ruff + args: [--exit-non-zero-on-fix, --fix] + - id: ruff-format + args: [--check] + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.35.1 + hooks: + - id: yamllint + args: [--strict] + - repo: https://github.com/hadolint/hadolint + rev: v2.12.0 + hooks: + - id: hadolint-docker + name: hadolint + - repo: https://github.com/woodruffw/zizmor-pre-commit + rev: v0.9.2 + hooks: + - id: zizmor diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f1d6e3e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,88 +0,0 @@ -sudo: required -dist: xenial -services: -- docker -python: 3.10 -language: python -cache: pip - -env: -# Linting and docs -- COMPOSE_APP=flake8 -- COMPOSE_APP=docs - -# Quick Runs. Lowest supported database and Python version. -- COMPOSE_APP=sqlite PYTHON_VERSION=3.10 -- COMPOSE_APP=sqlite-gis PYTHON_VERSION=3.10 -- COMPOSE_APP=postgres PYTHON_VERSION=3.10 POSTGRES_VERSION=13 -- COMPOSE_APP=postgres-gis PYTHON_VERSION=3.10 POSTGRES_VERSION=13 POSTGIS_VERSION=3.0 -- COMPOSE_APP=mysql PYTHON_VERSION=3.10 MYSQL_VERSION=8 -- COMPOSE_APP=mysql-gis PYTHON_VERSION=3.10 MYSQL_VERSION=8 -- COMPOSE_APP=mariadb PYTHON_VERSION=3.10 MARIADB_VERSION=10.5 - -# Sqlite -- COMPOSE_APP=sqlite PYTHON_VERSION=3.10 - -# Sqlite gis: -- COMPOSE_APP=sqlite-gis PYTHON_VERSION=3.10 - -# Postgres: -- COMPOSE_APP=postgres PYTHON_VERSION=3.10 POSTGRES_VERSION=13 -- COMPOSE_APP=postgres PYTHON_VERSION=3.10 POSTGRES_VERSION=14 -- COMPOSE_APP=postgres PYTHON_VERSION=3.10 POSTGRES_VERSION=15 -- COMPOSE_APP=postgres PYTHON_VERSION=3.10 POSTGRES_VERSION=16 - -# Postgres gis: -- COMPOSE_APP=postgres-gis PYTHON_VERSION=3.10 POSTGRES_VERSION=13 POSTGIS_VERSION=3.0 -- COMPOSE_APP=postgres-gis PYTHON_VERSION=3.10 POSTGRES_VERSION=14 POSTGIS_VERSION=3.1 -- COMPOSE_APP=postgres-gis PYTHON_VERSION=3.10 POSTGRES_VERSION=15 POSTGIS_VERSION=3.3 -- COMPOSE_APP=postgres-gis PYTHON_VERSION=3.10 POSTGRES_VERSION=16 POSTGIS_VERSION=3.4 - -# MySQL: -- COMPOSE_APP=mysql PYTHON_VERSION=3.10 MYSQL_VERSION=8.0 - -# MySQL gis: -- COMPOSE_APP=mysql-gis PYTHON_VERSION=3.10 MYSQL_VERSION=8.0 - -# MariaDB: -- COMPOSE_APP=mariadb PYTHON_VERSION=3.10 MARIADB_VERSION=10.5 -- COMPOSE_APP=mariadb PYTHON_VERSION=3.10 MARIADB_VERSION=10.6 -- COMPOSE_APP=mariadb PYTHON_VERSION=3.10 MARIADB_VERSION=10.11 -- COMPOSE_APP=mariadb PYTHON_VERSION=3.10 MARIADB_VERSION=11.0 -- COMPOSE_APP=mariadb PYTHON_VERSION=3.10 MARIADB_VERSION=11.1 - -# Browsers: -- COMPOSE_APP=chrome PYTHON_VERSION=3.10 -- COMPOSE_APP=firefox PYTHON_VERSION=3.10 - -matrix: - allow_failures: - - env: COMPOSE_APP=firefox PYTHON_VERSION=3.10 - -before_install: - - echo 'DOCKER_OPTS="${DOCKER_OPTS} --registry-mirror=https://mirror.gcr.io"' | sudo tee -a /etc/default/docker - - sudo service docker restart - -install: -- pip install docker-compose --upgrade - -script: -- git clone https://github.com/django/django.git --depth=1 /tmp/django -- export DJANGO_PATH=/tmp/django -- docker-compose pull --include-deps $COMPOSE_APP || true -- docker-compose build --pull $COMPOSE_APP -- | - if [[ $COMPOSE_APP == *-gis ]]; then - docker-compose run $COMPOSE_APP gis_tests - else - docker-compose run $COMPOSE_APP - fi - -after_failure: - - docker-compose logs - -deploy: - provider: script - script: bash docker_push.sh $COMPOSE_APP - on: - branch: main diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..c75ffeb --- /dev/null +++ b/Containerfile @@ -0,0 +1,66 @@ +# syntax=docker/dockerfile:1.12 + +ARG PYTHON_IMPLEMENTATION=python +ARG PYTHON_VERSION=3.10 +FROM ${PYTHON_IMPLEMENTATION}:${PYTHON_VERSION}-slim-bookworm + +LABEL org.opencontainers.image.authors="Django Software Foundation" +LABEL org.opencontainers.image.url="https://github.com/django/django-docker-box" +LABEL org.opencontainers.image.documentation="https://github.com/django/django-docker-box" +LABEL org.opencontainers.image.source="https://github.com/django/django-docker-box" +LABEL org.opencontainers.image.vendor="Django Software Foundation" +LABEL org.opencontainers.image.licenses="BSD-3-Clause" +LABEL org.opencontainers.image.title="Django Docker Box" +LABEL org.opencontainers.image.description="Container image for developing and testing Django." + +SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-o", "xtrace", "-c"] + +ENV DEBIAN_FRONTEND=noninteractive +ENV PYTHONUNBUFFERED=1 + +# Force colored output for various tooling in CI. +ENV COLUMNS=120 +ENV FORCE_COLOR=1 +ENV TERM="xterm-256color" + +# Create user and prepare directories. +RUN < /etc/apt/apt.conf.d/keep-cache + apt-get update --quiet --yes + xargs --arg-file=/django/packages.txt apt-get install --no-install-recommends --yes +EOF + +# Install all Python requirements in a single command. +COPY --chown=django:django requirements.txt /django/requirements/extra.txt +COPY --chown=django:django --from=src tests/requirements/ /django/requirements/ +COPY --chown=django:django --from=src docs/requirements.txt /django/requirements/docs.txt +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/ +RUN --mount=type=cache,target=/root/.cache/uv < [!IMPORTANT] +> As long as the two repositories are adjacent the Django source repository will be discovered. +> A different path can be specified by setting the `DJANGO_PATH` environment variable. -You can now either download the latest image used on the CI servers with the dependencies pre-installed: +3. Build the image: -`docker-compose pull sqlite` + ```console + $ docker compose build sqlite + ``` -Or build it yourself: +4. Run the tests: -`docker-compose build sqlite` + ```console + $ docker compose run --rm sqlite + ``` -Then simply run: -`docker-compose run --rm sqlite` +## Running Tests -All arguments are passed to `runtests.py`. Before they are run all specific dependencies are -installed (and cached across runs). +All of the test commands detailed below can be passed additional arguments that +are provided to the `runtests.py` entrypoint. You can see a list of these +arguments by running the following command: -## Different databases +```console +$ docker compose run --rm sqlite --help +``` -Simply substitute `sqlite` for any supported database: +### Standard Tests -`docker-compose run --rm postgres [args]` +To run the standard set of tests you can use the following commands: -`docker-compose run --rm mysql [args]` +```console +$ docker compose run --rm mariadb +$ docker compose run --rm mysql +$ docker compose run --rm oracle +$ docker compose run --rm postgres +$ docker compose run --rm sqlite +``` -`docker-compose run --rm mariadb [args]` +Each of the above commands will run the test suite for a different supported +database. -And if you're mad you can run all the tests for all databases in parallel: +More information about [running the unit tests][7] for Django can be found in +the documentation. -`docker-compose up` -#### Database versions +### Geospatial Tests -You can customize the version of the database you test against by changing the appropriate `[db]_VERSION` environment variable. See the Configuration section below for the available options and their defaults. +To run tests on geospatial features you can use the following commands: -## Different Python versions +```console +$ docker compose run --rm mariadb-gis +$ docker compose run --rm mysql-gis +$ docker compose run --rm oracle-gis +$ docker compose run --rm postgres-gis +$ docker compose run --rm sqlite-gis +``` -The `PYTHON_VERSION` environment variable customizes which version of Python you are running the tests against. e.g: +Each of the above commands will run the test suite for a different supported +geospatial database. -`PYTHON_VERSION=3.10 docker-compose run --rm sqlite` +> [!TIP] +> To only run the subset of tests for geospatial features, pass `gis_tests` as +> an argument to specify that only that folder of tests should be collected, +> e.g. +> +> ```console +> $ docker compose run --rm sqlite-gis gis_tests +> ``` -You can also pull the pre-built image in the same way: +More information about [running the GeoDjango tests][9] for Django can be found +in the documentation. -`PYTHON_VERSION=3.10 docker-compose pull sqlite` -## Oracle +### User Interface Tests -As usual Oracle is a bit more complex to set up. You need to download the latest `instantclient` **zip file** -[from this page](https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html) and place it inside the -`./oracle` directory. Ensure only one `.zip` file is present. +To run tests on user interfaces you can use the following commands: -The database image is quite large (several gigabytes) and takes a fairly long time to initialise (5-10 minutes). -Once it has initialised subsequent starts should be very quick. To begin this process run: - - `docker-compose run oracle-db` +```console +$ docker compose run --rm chrome +$ docker compose run --rm edge +$ docker compose run --rm firefox +``` -And wait for it to initialize. Once it has, use ctrl+c to terminate it and execute: +Each of the above commands will run the subset of user interface tests for a +different supported web browser. The tests are executed using Selenium. -`docker-compose run --rm oracle` +To capture screenshots of certain test cases used for comparison to avoid +regressions, the `--screenshots` flag can be passed. -To run the test suite against it. All other databases support different versions, however Oracle does not. +More information about [running the Selenium tests][8] for Django can be found +in the documentation. -## Utilities -To run the docs spellchecker: +## Running Tools -`docker-compose run --rm docs` -Or flake8: +### Linting & Formatting -`docker-compose run --rm flake8` +Django uses the following linting and formatting tools: `black`, `flake8`, +`isort`, and `eslint`. To ensure that the correct versions are used, Django +also supports using `pre-commit` which is the mechanism provided here: -To enter a bash shell within the container, run: +```console +$ docker compose run --rm pre-commit +``` -`docker-compose run --rm --entrypoint bash [database]` +You can run individual tools by passing them as an argument: -## Configuration +```console +$ docker compose run --rm pre-commit black +$ docker compose run --rm pre-commit blacken-docs +$ docker compose run --rm pre-commit isort +$ docker compose run --rm pre-commit flake8 +$ docker compose run --rm pre-commit eslint # XXX: Currently not working. +``` + +More information about Django's [coding style][5] can be found in the +documentation. + +### Building Documentation + +Documentation for Django is built using Sphinx. Run the following to see the +available commands: + +```console +$ docker compose run --rm sphinx +``` -| Environment Variable | Default | Description | -| --- | --- | --- | -| `DJANGO_PATH` | None | The path to the Django codebase on your local machine | -| `PYTHON_VERSION` | `3.10` | The python version to run tests against | -| `POSTGRES_VERSION` | `13` | The version of Postgres to use | -| `MYSQL_VERSION` | `8` | The mysql version to use | -| `MARIADB_VERSION` | `10.5` | The mariadb version to use | +You may find the following builders particularly useful when working on +documentation improvements: +```console +$ docker compose run --rm sphinx dirhtml +$ docker compose run --rm sphinx spelling +$ docker compose run --rm sphinx linkcheck +``` -## Why? +The `BUILDDIR` environment variable has been set to generate output into the +`./output/docs` path under this repository instead of the usual location in the +Django source repository. You can alter this environment variable to generate +to a different path if required. + +More information about [writing documentation][6] for Django can be found in +the documentation. + + +### Other + +To enter a shell within the container, run: + +```console +$ docker compose run --rm --entrypoint=bash sqlite +``` + +## Configuration -I prefer using docker over Vagrant and virtualbox, which is what django-box uses. I think this -approach is also simpler to quickly change the various database/python versions the test suite -runs across. However both approaches work, so use whatever floats your boat. +The build of the container image can be customized by setting the following +environment variables: + +| Environment Variable | Default Value | Description | +| ----------------------- | ------------- | ---------------------------------------------------- | +| `DJANGO_PATH` | `../django` | Path to the Django repostory on your local machine | +| `PYTHON_IMPLEMENTATION` | `python` | Implementation of Python to use — `python` or `pypy` | +| `PYTHON_VERSION` | `3.10` | Version of Python container image to use | + +The versions of various backend services can be switched by setting these environment variables: + +| Environment Variable | Default Value | Description | +| ----------------------- | ------------- | ---------------------------------------------------- | +| `MARIADB_VERSION` | `10.5` | Version of MariaDB container image to use | +| `MYSQL_VERSION` | `8.0` | Version of MySQL container image to use | +| `ORACLE_VERSION` | `23.5.0.0` | Version of Oracle container image to use | +| `POSTGRESQL_VERSION` | `14` | Version of PostgreSQL container image to use | +| `POSTGIS_VERSION` | `3.1` | Version of PostGIS extension to use | + + +### Python Versions + +The `PYTHON_VERSION` environment variable controls which version of Python you +are running the tests against, e.g. + +```console +$ PYTHON_VERSION=3.10 docker compose run --rm sqlite +``` + +In addition, it's possible to select a different implementation of Python, i.e. +PyPy instead of CPython, by setting the `PYTHON_IMPLEMENTATION` environment +variable, e.g. + +```console +$ PYTHON_IMPLEMENTATION=pypy docker compose run --rm sqlite +``` + +Be warned, however, that support for PyPy is not as complete and there are more +restrictions with respect to the range of versions available. + +### Database Versions + +Most database container images are pulled from [Docker Hub][2]. Oracle database +is pulled from the [Oracle Container Registry][3]. + +You can switch the version of the database you test against by changing the +appropriate environment variable. Available options and their defaults can be +found in the [configuration section](#Configuration). + +> [!WARNING] +> Be aware that only a single version of a particular database may be running +> at one time, so you will need to ensure that you tear down the previously +> running instance before starting up the new one, e.g. +> +> ```console +> $ docker compose ps --format='{{.Image}}' postgresql-db +> postgres:13-alpine +> $ docker compose down postgresql-db +> [+] Running 1/1 +> ✔ Container django-docker-box-postgresql-db-1 Removed 0.2s +> $ POSTGRESQL_VERSION=17 docker compose up --detach postgresql-db +> [+] Running 1/1 +> ✔ Container django-docker-box-postgresql-db-1 Started 0.3s +> $ docker compose ps --format='{{.Image}}' postgresql-db +> postgres:17-alpine +> ``` +> +> Alternatively, run the following to tear down the whole stack before bringing +> up new containers running different versions: +> +> ```console +> $ docker compose down +> ``` + +> [!NOTE] +> +> Unlike other GIS database backends, for PostgreSQL with PostGIS you will need +> to specify both versions: +> +> ```console +> $ POSTGRESQL_VERSION=17 POSTGIS_VERSION=3.5 docker compose up --detach postgresql-gis-db +> ``` + +To determine what database versions can be used you can check the release notes +for the branch of Django that you have checked out, or alternatively there is +the [supported database versions][4] page on Django's Trac Wiki. + + +### Other Versions + +For the Memcached, Redis, and Selenium container images, the latest container +image tag is always used. + +Where possible, for backend services, we also use Alpine images where available +for smaller image size and sometimes improved performance. + + +## Roadmap + +The following list is a collection of ideas for improvements that could be made +with no promises that they'll be delivered: + +- Add a monthly scheduled full test matrix execution using GitHub Actions +- Add support for some third-party databases, e.g. CockroachDB, SQL Server +- Add support for test coverage execution and report generation +- Add support for running accessibility tooling and report generation +- Support report generation during monthly runs and publish to GitHub Pages +- Publish pre-built container images to the GitHub Container Registry +- Support testing against different versions of SQLite and SpatiaLite +- Support running with Podman in addition to Docker +- Support generating screenshots into `./output/screenshots/` + + +[0]: https://www.djangoproject.com/ +[1]: https://www.djangoproject.com/fundraising/ +[2]: https://hub.docker.com/search?badges=official&badges=open_source +[3]: https://container-registry.oracle.com/ords/ocr/ba/database/free +[4]: https://code.djangoproject.com/wiki/SupportedDatabaseVersions +[5]: https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/ +[6]: https://docs.djangoproject.com/en/stable/internals/contributing/writing-documentation/ +[7]: https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/unit-tests/#running-the-unit-tests +[8]: https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/unit-tests/#running-the-selenium-tests +[9]: https://docs.djangoproject.com/en/stable/ref/contrib/gis/testing/#geodjango-tests diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..fc65ac7 --- /dev/null +++ b/compose.yml @@ -0,0 +1,402 @@ +--- + +x-base: &base + image: django-docker-box:${PYTHON_IMPLEMENTATION}-${PYTHON_VERSION} + build: + context: . + dockerfile: ./Containerfile + args: + - PYTHON_IMPLEMENTATION=${PYTHON_IMPLEMENTATION} + - PYTHON_VERSION=${PYTHON_VERSION} + additional_contexts: + src: ${DJANGO_PATH:-../django} + volumes: + - ${DJANGO_PATH:-../django}:/django/source:rw + - ./output:/django/output:rw + - ./settings.py:/django/source/tests/settings.py:ro + - user-cache:/django/.cache/:rw + +x-mysql-base: &mysql-base + environment: + - MYSQL_ALLOW_EMPTY_PASSWORD=1 + - MYSQL_DATABASE=django + - MYSQL_PASSWORD=django + - MYSQL_USER=django + tmpfs: + - /var/lib/mysql + deploy: + mode: global + restart: unless-stopped + healthcheck: &mysql-base-healthcheck + interval: 5s + timeout: 5s + retries: 3 + start_period: 10s + start_interval: 1s + volumes: + - ./startup-mysql.sql:/docker-entrypoint-initdb.d/django.sql:ro + +x-oracle-base: &oracle-base + environment: + - ORACLE_PWD=oracle + deploy: + mode: global + restart: unless-stopped + healthcheck: + test: /opt/oracle/checkDBStatus.sh + interval: 5s + timeout: 5s + retries: 3 + start_period: 10s + start_interval: 1s + volumes: + - ./startup-oracle.sql:/opt/oracle/scripts/startup/django.sql:ro + +x-postgresql-base: &postgresql-base + environment: + - POSTGRES_DB=django + - POSTGRES_PASSWORD=django + - POSTGRES_USER=django + tmpfs: + - /var/lib/postgresql + deploy: + mode: global + restart: unless-stopped + healthcheck: + test: pg_isready --quiet --username=django + interval: 5s + timeout: 5s + retries: 3 + start_period: 10s + start_interval: 1s + command: >- + -c archive_mode=off + -c checkpoint_completion_target=0.9 + -c checkpoint_timeout=900 + -c fsync=off + -c full_page_writes=off + -c max_replication_slots=0 + -c max_wal_senders=0 + -c max_wal_size=4096 + -c synchronous_commit=off + -c wal_level=minimal + # 13+: -c wal_keep_size=0 + +x-memcached: &memcached-base + image: memcached:alpine + deploy: + mode: global + restart: unless-stopped + healthcheck: + test: echo stats | nc 127.0.0.1 11211 + interval: 5s + timeout: 5s + retries: 3 + start_period: 10s + start_interval: 1s + command: >- + --conn-limit=1024 + --memory-limit=64 + --threads=4 + +x-redis: &redis-base + image: redis:alpine + deploy: + mode: global + restart: unless-stopped + healthcheck: + test: redis-cli ping | grep -i pong + interval: 5s + timeout: 5s + retries: 3 + start_period: 10s + start_interval: 1s + +x-cache-depends: &depends-on-caches + memcached-1: + condition: service_healthy + memcached-2: + condition: service_healthy + redis: + condition: service_healthy + +x-selenium-base: &selenium-base + shm_size: 2gb + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + - SE_NODE_GRID_URL=http://selenium-hub:4444 + depends_on: + selenium-hub: + condition: service_started + deploy: + mode: global + restart: unless-stopped + +volumes: + user-cache: + +services: + + # Services: Databases + + mariadb-db: + <<: *mysql-base + image: &mariadb-image mariadb:${MARIADB_VERSION} + command: &mariadb-command >- + --innodb-fast-shutdown=3 + --innodb-flush-log-at-trx-commit=0 + --innodb-flush-method=nosync + --innodb-random-read-ahead + --skip-innodb-doublewrite + --skip-innodb-file-per-table + --skip-innodb-flush-sync + --skip-innodb-use-atomic-writes + --skip-name-resolve + healthcheck: &mariadb-healthcheck + <<: *mysql-base-healthcheck + test: healthcheck.sh --connect + + mariadb-gis-db: + <<: *mysql-base + image: *mariadb-image + command: *mariadb-command + healthcheck: *mariadb-healthcheck + + mysql-db: + <<: *mysql-base + image: &mysql-image mysql:${MYSQL_VERSION} + command: &mysql-command >- + --innodb-flush-log-at-trx-commit=0 + --innodb-flush-method=nosync + --innodb-random-read-ahead + --skip-innodb-doublewrite + --skip-innodb-extend-and-initialize + --skip-innodb-file-per-table + --skip-innodb-flush-sync + --skip-name-resolve + healthcheck: &mysql-healthcheck + <<: *mysql-base-healthcheck + test: mysqladmin ping --silent + + mysql-gis-db: + <<: *mysql-base + image: *mysql-image + command: *mysql-command + healthcheck: *mysql-healthcheck + + oracle-db: + <<: *oracle-base + # yamllint disable-line rule:line-length + image: &oracle-image container-registry.oracle.com/database/free:${ORACLE_VERSION}-lite + + oracle-gis-db: + <<: *oracle-base + image: *oracle-image + + postgresql-db: + <<: *postgresql-base + image: postgres:${POSTGRESQL_VERSION}-alpine + + postgresql-gis-db: + <<: *postgresql-base + image: postgis/postgis:${POSTGRESQL_VERSION}-${POSTGIS_VERSION}-alpine + + # Services: Caches + + memcached-1: + <<: *memcached-base + + memcached-2: + <<: *memcached-base + + redis: + <<: *redis-base + + # Services: Selenium + + selenium-chrome: + <<: *selenium-base + image: selenium/node-chrome + + selenium-edge: + <<: *selenium-base + image: selenium/node-edge + + selenium-firefox: + <<: *selenium-base + image: selenium/node-firefox + + selenium-hub: + image: selenium/hub + ports: + - "4442-4444:4442-4444" + deploy: + mode: global + restart: unless-stopped + healthcheck: + test: /opt/bin/check-grid.sh + interval: 15s + timeout: 30s + retries: 5 + + # Commands: Tests + + mariadb: + <<: *base + depends_on: + <<: *depends-on-caches + mariadb-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.db.backends.mysql + - DATABASE_HOST=mariadb-db + + mysql: + <<: *base + depends_on: + <<: *depends-on-caches + mysql-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.db.backends.mysql + - DATABASE_HOST=mysql-db + + oracle: + <<: *base + depends_on: + <<: *depends-on-caches + oracle-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.db.backends.oracle + - DATABASE_NAME=oracle-db:1521/freepdb1 + + postgresql: + <<: *base + depends_on: + <<: *depends-on-caches + postgresql-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.db.backends.postgresql + - DATABASE_HOST=postgresql-db + + sqlite: + <<: *base + depends_on: + <<: *depends-on-caches + environment: + - DATABASE_ENGINE=django.db.backends.sqlite3 + + # Commands: Tests: GIS + + mariadb-gis: + <<: *base + depends_on: + <<: *depends-on-caches + mariadb-gis-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.contrib.gis.db.backends.mysql + - DATABASE_HOST=mariadb-gis-db + + mysql-gis: + <<: *base + depends_on: + <<: *depends-on-caches + mysql-gis-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.contrib.gis.db.backends.mysql + - DATABASE_HOST=mysql-gis-db + + oracle-gis: + <<: *base + depends_on: + <<: *depends-on-caches + oracle-gis-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.contrib.gis.db.backends.oracle + - DATABASE_NAME=oracle-gis-db:1521/freepdb1 + + postgresql-gis: + <<: *base + depends_on: + <<: *depends-on-caches + postgresql-gis-db: + condition: service_healthy + environment: + - DATABASE_ENGINE=django.contrib.gis.db.backends.postgis + - DATABASE_HOST=postgresql-gis-db + + sqlite-gis: + <<: *base + depends_on: + <<: *depends-on-caches + environment: + - DATABASE_ENGINE=django.contrib.gis.db.backends.spatialite + + # Commands: Tests: Selenium + + chrome: + <<: *base + entrypoint: >- + /django/entrypoint.bash + --selenium=chrome + --selenium-hub=http://selenium-hub:4444/wd/hub + depends_on: + selenium-hub: + condition: service_healthy + selenium-chrome: + condition: service_started + environment: + - DATABASE_ENGINE=django.db.backends.sqlite3 + + edge: + <<: *base + entrypoint: >- + /django/entrypoint.bash + --selenium=edge + --selenium-hub=http://selenium-hub:4444/wd/hub + depends_on: + selenium-hub: + condition: service_healthy + selenium-edge: + condition: service_started + environment: + - DATABASE_ENGINE=django.db.backends.sqlite3 + + firefox: + <<: *base + entrypoint: >- + /django/entrypoint.bash + --selenium=firefox + --selenium-hub=http://selenium-hub:4444/wd/hub + depends_on: + selenium-hub: + condition: service_healthy + selenium-firefox: + condition: service_started + environment: + - DATABASE_ENGINE=django.db.backends.sqlite3 + + # Commands: Other + + pre-commit: + <<: *base + entrypoint: pre-commit run --all-files + working_dir: /django/source + environment: + # XXX: Disable eslint due to issues finding dependencies. + # See https://github.com/django/django/pull/18162 + SKIP: eslint + + sphinx: + <<: *base + entrypoint: make + working_dir: /django/source/docs + environment: + BUILDDIR: /django/output/docs diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 638f883..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,184 +0,0 @@ -version: "2.3" - -x-base: &base - image: djangobox/django-docker-box:${PYTHON_VERSION} - build: - context: ${DJANGO_PATH} - dockerfile: ${PWD}/Dockerfile - args: - - PYTHON_VERSION=${PYTHON_VERSION} - cache_from: - - djangobox/django-docker-box:${PYTHON_VERSION} - volumes: - - ${DJANGO_PATH}:/tests/django/ - - ./settings:/tests/django/tests/settings - - ./oracle_entrypoint.sh:/oracle_entrypoint.sh - # Using yaml merging here overwrites the arrays. Simpler to just mount this in every service. - - ./oracle:/oracle - entrypoint: bash -c "wait-for-it.sh -s -t 20 $${WAIT_FOR} -- python runtests.py $$@" -- - -x-postgres-base: &postgres-base - environment: - - POSTGRES_USER=django - - POSTGRES_PASSWORD=django - - POSTGRES_DB=django - # Set a few options to speed up postgresql tests. - command: -c fsync=off -c synchronous_commit=off -c full_page_writes=off - tmpfs: - - /var/lib/postgresql - -services: - sqlite: - <<: *base - environment: - - DJANGO_SETTINGS_MODULE=settings.test_sqlite - entrypoint: python runtests.py - depends_on: - - memcached - - memcached2 - - sqlite-gis: - <<: *base - entrypoint: python runtests.py - environment: - - DJANGO_SETTINGS_MODULE=settings.test_sqlite_gis - - postgres: - <<: *base - environment: - - DJANGO_SETTINGS_MODULE=settings.test_postgres - - WAIT_FOR=postgres-db:5432 - depends_on: - - postgres-db - - memcached - - memcached2 - postgres-db: - <<: *postgres-base - image: postgres:${POSTGRES_VERSION}-alpine - - postgres-gis: - <<: *base - environment: - - DJANGO_SETTINGS_MODULE=settings.test_postgres_gis - - WAIT_FOR=postgres-gis-db:5432 - depends_on: - - postgres-gis-db - postgres-gis-db: - <<: *postgres-base - image: postgis/postgis:${POSTGRES_VERSION}-${POSTGIS_VERSION} - - mysql: - <<: *base - environment: - - DJANGO_SETTINGS_MODULE=settings.test_mysql - - WAIT_FOR=mysql-db:3306 - depends_on: - - mysql-db - - memcached - - memcached2 - mysql-db: &mysql_base - image: mysql:${MYSQL_VERSION} - entrypoint: ['/entrypoint.sh', '--default-authentication-plugin=mysql_native_password'] - tmpfs: - - /var/lib/mysql - environment: - - MYSQL_USER=django - - MYSQL_PASSWORD=django - - MYSQL_DATABASE=django - - MYSQL_ALLOW_EMPTY_PASSWORD=1 - - mysql-gis: - <<: *base - environment: - - DJANGO_SETTINGS_MODULE=settings.test_mysql_gis - - WAIT_FOR=mysql-gis-db:3306 - depends_on: - - mysql-gis-db - mysql-gis-db: - <<: *mysql_base - volumes: - - /var/lib/mysql - - mariadb: - <<: *base - environment: - - DJANGO_SETTINGS_MODULE=settings.test_mariadb - - WAIT_FOR=mariadb-db:3306 - depends_on: - - mariadb-db - - memcached - - memcached2 - mariadb-db: - image: mariadb:${MARIADB_VERSION} - tmpfs: - - /var/lib/mysql - environment: - - MYSQL_USER=django - - MYSQL_PASSWORD=django - - MYSQL_DATABASE=django - - MYSQL_ALLOW_EMPTY_PASSWORD=1 - - oracle: - <<: *base - image: djangobox/django-docker-box:oracle-${PYTHON_VERSION} - environment: - - DJANGO_SETTINGS_MODULE=settings.test_oracle - - WAIT_FOR=oracle-db:1521 - entrypoint: /oracle_entrypoint.sh python runtests.py - depends_on: - - oracle-db - - memcached - - memcached2 - oracle-db: - image: sath89/oracle-12c - volumes: - - oracle:/u01/app/oracle/ - environment: - - WEB_CONSOLE=false - - memcached: &memcached - image: memcached:alpine - - memcached2: - <<: *memcached - - docs: - <<: *base - entrypoint: ["make", "spelling"] - working_dir: /tests/django/docs - user: root - - flake8: - <<: *base - entrypoint: flake8 - - # Browser tests - chrome: - <<: *base - command: --selenium=chrome --selenium-hub=http://chrome-browser:4444/wd/hub - environment: - - WAIT_FOR=chrome-browser:4444 - depends_on: - - chrome-browser - chrome-browser: - image: selenium/standalone-chrome - volumes: - - /dev/shm:/dev/shm - - # Firefox tests fail on main - firefox: - <<: *base - command: --selenium=firefox --selenium-hub=http://firefox-browser:4444/wd/hub - environment: - - WAIT_FOR=firefox-browser:4444 - depends_on: - - firefox-browser - firefox-browser: - image: selenium/standalone-firefox - volumes: - - /dev/shm:/dev/shm - - -volumes: - oracle: - diff --git a/docker_push.sh b/docker_push.sh deleted file mode 100644 index 915046e..0000000 --- a/docker_push.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin -docker-compose push $@ diff --git a/entrypoint.bash b/entrypoint.bash new file mode 100755 index 0000000..a3c8702 --- /dev/null +++ b/entrypoint.bash @@ -0,0 +1,3 @@ +#!/bin/bash + +python -Wall runtests.py ${@} diff --git a/oracle/.gitkeep b/oracle/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/oracle_entrypoint.sh b/oracle_entrypoint.sh deleted file mode 100755 index 18a333b..0000000 --- a/oracle_entrypoint.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -IFS=$'\n\t' - -if compgen -G "/oracle/*.zip" > /dev/null; then - sudo mkdir -p /opt/oracle - sudo unzip /oracle/*.zip -d /opt/oracle - sudo bash -c "echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf" - sudo ldconfig -fi -exec $@ diff --git a/output/.gitignore b/output/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/output/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/packages.txt b/packages.txt new file mode 100644 index 0000000..14a4662 --- /dev/null +++ b/packages.txt @@ -0,0 +1,17 @@ +binutils +build-essential +default-libmysqlclient-dev +default-mysql-client +gdal-bin +gettext +git +libaio-dev +libenchant-2-dev +libgdal-dev +libgeoip-dev +libmemcached-dev +libpq-dev +libproj-dev +libsqlite3-mod-spatialite +pkg-config +unzip diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c31c519 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +black +pre-commit +unittest-xml-reporting diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..40cd183 --- /dev/null +++ b/settings.py @@ -0,0 +1,70 @@ +import os + + +def _build_databases_setting(): + engine = os.environ["DATABASE_ENGINE"] + host = os.environ.get("DATABASE_HOST", "") + name = os.environ.get("DATABASE_NAME", "") + settings = {} + + for n, alias in enumerate(("default", "other"), start=1): + settings[alias] = entry = {"ENGINE": engine} + + if not engine.endswith((".sqlite", ".spatialite")): + entry |= { + "HOST": host, + "NAME": "django" if n < 2 else f"django{n}", + "USER": "django", + "PASSWORD": "django", + } + + if engine.endswith(".mysql"): + entry["TEST"] = {"CHARSET": "utf8mb4"} + + if engine.endswith(".oracle"): + entry |= { + "NAME": name, + "TEST": { + "USER": f"{alias}_test", + "TBLSPACE": f"{alias}_test_tbls", + "TBLSPACE_TMP": f"{alias}_test_tbls_tmp", + }, + } + + return settings + + +CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + }, + "pymemcache": { + "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache", + "LOCATION": "memcached-1:11211", + "KEY_PREFIX": "pymemcache:", + }, + "pylibmc": { + "BACKEND": "django.core.cache.backends.memcached.PyLibMCCache", + "LOCATION": "memcached-2:11211", + "KEY_PREFIX": "pylibmc:", + }, + "redis-py": { + "BACKEND": "django.core.cache.backends.redis.RedisCache", + "LOCATION": "redis://redis:6379", + "KEY_PREFIX": "redis:", + }, +} + +DATABASES = _build_databases_setting() + +DEFAULT_AUTO_FIELD = "django.db.models.AutoField" + +PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"] + +SECRET_KEY = "django_tests_secret_key" + +USE_TZ = False + +if os.environ.get("XUNIT", "0").lower() in {"1", "on", "true", "yes"}: + TEST_RUNNER = "xmlrunner.extra.djangotestrunner.XMLTestRunner" + TEST_OUTPUT_DIR = "/django/output/xunit" diff --git a/settings/__init__.py b/settings/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/settings/test_mariadb.py b/settings/test_mariadb.py deleted file mode 100644 index 82069ac..0000000 --- a/settings/test_mariadb.py +++ /dev/null @@ -1,50 +0,0 @@ -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'USER': 'root', - 'PASSWORD': '', - 'NAME': 'django', - 'HOST': 'mariadb-db', - 'TEST': { - 'CHARSET': 'utf8', - }, - }, - 'other': { - 'ENGINE': 'django.db.backends.mysql', - 'USER': 'root', - 'PASSWORD': '', - 'NAME': 'django2', - 'HOST': 'mariadb-db', - 'TEST': { - 'CHARSET': 'utf8', - }, - }, -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - }, - 'pymemcache': { - 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', - 'LOCATION': 'memcached:11211', - 'KEY_PREFIX': 'pymemcache:', - }, - 'pylibmc': { - 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', - 'LOCATION': 'memcached2:11211', - 'KEY_PREFIX': 'pylibmc:', - }, -} - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results/' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/settings/test_mysql.py b/settings/test_mysql.py deleted file mode 100644 index b05ace0..0000000 --- a/settings/test_mysql.py +++ /dev/null @@ -1,50 +0,0 @@ -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'USER': 'root', - 'PASSWORD': '', - 'NAME': 'django', - 'HOST': 'mysql-db', - 'TEST': { - 'CHARSET': 'utf8', - }, - }, - 'other': { - 'ENGINE': 'django.db.backends.mysql', - 'USER': 'root', - 'PASSWORD': '', - 'NAME': 'django2', - 'HOST': 'mysql-db', - 'TEST': { - 'CHARSET': 'utf8', - }, - }, -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - }, - 'pymemcache': { - 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', - 'LOCATION': 'memcached:11211', - 'KEY_PREFIX': 'pymemcache:', - }, - 'pylibmc': { - 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', - 'LOCATION': 'memcached2:11211', - 'KEY_PREFIX': 'pylibmc:', - }, -} - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results/' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/settings/test_mysql_gis.py b/settings/test_mysql_gis.py deleted file mode 100644 index 6185cd1..0000000 --- a/settings/test_mysql_gis.py +++ /dev/null @@ -1,36 +0,0 @@ -DATABASES = { - 'default': { - 'ENGINE': 'django.contrib.gis.db.backends.mysql', - 'USER': 'root', - 'PASSWORD': '', - 'NAME': 'django', - 'HOST': 'mysql-gis-db', - 'TEST': { - 'CHARSET': 'utf8', - }, - }, - 'other': { - 'ENGINE': 'django.contrib.gis.db.backends.mysql', - 'USER': 'root', - 'PASSWORD': '', - 'NAME': 'django2', - 'HOST': 'mysql-gis-db', - 'TEST': { - 'CHARSET': 'utf8', - }, - }, -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - -GEOIP_PATH = '/geolite2/' - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results/' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/settings/test_oracle.py b/settings/test_oracle.py deleted file mode 100644 index 99e4775..0000000 --- a/settings/test_oracle.py +++ /dev/null @@ -1,52 +0,0 @@ -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.oracle', - 'NAME': 'oracle-db:1521/xe', - 'USER': 'system', - 'PASSWORD': 'oracle', - 'TEST': { - 'USER': 'default_test', - 'TBLSPACE': 'default_test_tbls', - 'TBLSPACE_TMP': 'default_test_tbls_tmp', - }, - }, - 'other': { - 'ENGINE': 'django.db.backends.oracle', - 'NAME': 'oracle-db:1521/xe', - 'USER': 'system', - 'PASSWORD': 'oracle', - 'TEST': { - 'USER': 'other_test', - 'TBLSPACE': 'other_test_tbls', - 'TBLSPACE_TMP': 'other_test_tbls_tmp', - }, - }, -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - }, - 'pymemcache': { - 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', - 'LOCATION': 'memcached:11211', - 'KEY_PREFIX': 'pymemcache:', - }, - 'pylibmc': { - 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', - 'LOCATION': 'memcached2:11211', - 'KEY_PREFIX': 'pylibmc:', - }, -} - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results/' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/settings/test_postgres.py b/settings/test_postgres.py deleted file mode 100644 index 85148ba..0000000 --- a/settings/test_postgres.py +++ /dev/null @@ -1,58 +0,0 @@ -# This is an example test settings file for use with the Django test suite. -# -# The 'sqlite3' backend requires only the ENGINE setting (an in- -# memory database will be used). All other backends will require a -# NAME and potentially authentication information. See the -# following section in the docs for more information: -# -# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ -# -# The different databases that Django supports behave differently in certain -# situations, so it is recommended to run the test suite against as many -# database backends as possible. You may want to create a separate settings -# file for each of the backends you test against. - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'USER': 'django', - 'PASSWORD': 'django', - 'NAME': 'django', - 'HOST': 'postgres-db' - }, - 'other': { - 'ENGINE': 'django.db.backends.postgresql', - 'USER': 'django', - 'NAME': 'django2', - 'PASSWORD': 'django', - 'HOST': 'postgres-db' - } -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - }, - 'pymemcache': { - 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', - 'LOCATION': 'memcached:11211', - 'KEY_PREFIX': 'pymemcache:', - }, - 'pylibmc': { - 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', - 'LOCATION': 'memcached2:11211', - 'KEY_PREFIX': 'pylibmc:', - }, -} - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results/' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/settings/test_postgres_gis.py b/settings/test_postgres_gis.py deleted file mode 100644 index 1e70561..0000000 --- a/settings/test_postgres_gis.py +++ /dev/null @@ -1,44 +0,0 @@ -# This is an example test settings file for use with the Django test suite. -# -# The 'sqlite3' backend requires only the ENGINE setting (an in- -# memory database will be used). All other backends will require a -# NAME and potentially authentication information. See the -# following section in the docs for more information: -# -# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ -# -# The different databases that Django supports behave differently in certain -# situations, so it is recommended to run the test suite against as many -# database backends as possible. You may want to create a separate settings -# file for each of the backends you test against. - -DATABASES = { - 'default': { - 'ENGINE': 'django.contrib.gis.db.backends.postgis', - 'USER': 'django', - 'PASSWORD': 'django', - 'NAME': 'django', - 'HOST': 'postgres-gis-db' - }, - 'other': { - 'ENGINE': 'django.contrib.gis.db.backends.postgis', - 'USER': 'django', - 'NAME': 'django2', - 'PASSWORD': 'django', - 'HOST': 'postgres-gis-db' - } -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - -GEOIP_PATH = '/geolite2/' - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/settings/test_sqlite.py b/settings/test_sqlite.py deleted file mode 100644 index 1974bec..0000000 --- a/settings/test_sqlite.py +++ /dev/null @@ -1,51 +0,0 @@ -# This is an example test settings file for use with the Django test suite. -# -# The 'sqlite3' backend requires only the ENGINE setting (an in- -# memory database will be used). All other backends will require a -# NAME and potentially authentication information. See the -# following section in the docs for more information: -# -# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ -# -# The different databases that Django supports behave differently in certain -# situations, so it is recommended to run the test suite against as many -# database backends as possible. You may want to create a separate settings -# file for each of the backends you test against. - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - }, - 'other': { - 'ENGINE': 'django.db.backends.sqlite3', - } -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - }, - 'pymemcache': { - 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', - 'LOCATION': 'memcached:11211', - 'KEY_PREFIX': 'pymemcache:', - }, - 'pylibmc': { - 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', - 'LOCATION': 'memcached2:11211', - 'KEY_PREFIX': 'pylibmc:', - }, -} - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/settings/test_sqlite_gis.py b/settings/test_sqlite_gis.py deleted file mode 100644 index 55173c1..0000000 --- a/settings/test_sqlite_gis.py +++ /dev/null @@ -1,36 +0,0 @@ -# This is an example test settings file for use with the Django test suite. -# -# The 'sqlite3' backend requires only the ENGINE setting (an in- -# memory database will be used). All other backends will require a -# NAME and potentially authentication information. See the -# following section in the docs for more information: -# -# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ -# -# The different databases that Django supports behave differently in certain -# situations, so it is recommended to run the test suite against as many -# database backends as possible. You may want to create a separate settings -# file for each of the backends you test against. - -DATABASES = { - 'default': { - 'ENGINE': 'django.contrib.gis.db.backends.spatialite', - }, - 'other': { - 'ENGINE': 'django.contrib.gis.db.backends.spatialite', - } -} - -SECRET_KEY = "django_tests_secret_key" - -# Use a fast hasher to speed up tests. -PASSWORD_HASHERS = [ - 'django.contrib.auth.hashers.MD5PasswordHasher', -] - -GEOIP_PATH = '/geolite2/' - -TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' -TEST_OUTPUT_DIR = '/tests/results/' -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' -USE_TZ = False diff --git a/startup-mysql.sql b/startup-mysql.sql new file mode 100644 index 0000000..4f947cf --- /dev/null +++ b/startup-mysql.sql @@ -0,0 +1 @@ +GRANT ALL PRIVILEGES ON *.* TO 'django'@'%' WITH GRANT OPTION; diff --git a/startup-oracle.sql b/startup-oracle.sql new file mode 100644 index 0000000..92ae6b1 --- /dev/null +++ b/startup-oracle.sql @@ -0,0 +1,3 @@ +ALTER SESSION SET CONTAINER=FREEPDB1; +CREATE USER django IDENTIFIED BY django; +GRANT DBA TO django;