Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: tests are broken #7

Merged
merged 1 commit into from
Jun 20, 2017
Merged

Problem: tests are broken #7

merged 1 commit into from
Jun 20, 2017

Conversation

sevein
Copy link
Collaborator

@sevein sevein commented Jun 18, 2017

Some fixes to get our tests working again inside Docker:

  • storage_service.settings.test: disable whitenoise
  • locations/fixtures/package.json: use json empty document default
  • Dockerfile: add p7zip missing dependency
  • Dockerfile: add workdir
  • Dockerfile: add pythonpath

This is how you can run them to verify the fixes:

$ docker-compose run --rm --no-deps --entrypoint pytest \
	-e "DJANGO_SETTINGS_MODULE=storage_service.settings.test" \
		archivematica-storage-service

You can pass arguments to pytest, e.g.:

$ docker-compose run --rm --no-deps --entrypoint pytest \
	-e "DJANGO_SETTINGS_MODULE=storage_service.settings.test" \
		archivematica-storage-service \
			-x locations/tests/test_api.py

... meaning that you want to run only the tests under test_api.py and stop the process after hitting the first failing test.

@sevein sevein requested review from helenst and jhsimpson June 18, 2017 18:18
@sevein sevein added this to the MVP milestone Jun 18, 2017
@@ -44,7 +44,7 @@
"size": 0,
"package_type": "Transfer",
"status": "Uploaded",
"misc_attributes": ""
"misc_attributes": "{}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string is not a valid JSON document, causing the fixture loader to break. This probably started happening when we updated jsonfield.

@jhsimpson
Copy link

To run the docker-compose command you suggest, is it necessary to be testing from the rdss-archivematica repo?

I don't see a docker-compose.yml in this PR.

@sevein
Copy link
Collaborator Author

sevein commented Jun 20, 2017 via email

@sevein
Copy link
Collaborator Author

sevein commented Jun 20, 2017 via email

@sevein
Copy link
Collaborator Author

sevein commented Jun 20, 2017

This should work:

$ docker run --rm --entrypoint pytest \
    --env "DJANGO_SETTINGS_MODULE=storage_service.settings.test" \
    --env "SS_DB_NAME=_" \
    --env "SS_DB_USER=_" \
    --env "SS_DB_PASSWORD=_" \
    --env "SS_DB_HOST=_" \
    --env "DJANGO_SECRET_KEY=_" \
    --env "DJANGO_ALLOWED_HOSTS=_" \
    --user "root" ss

But I'll make a couple of changes so we don't need root and all the extra environment strings. I shouldn't use get_env_variable in base.py but in the modules importing base. 🤦‍♂️

@sevein
Copy link
Collaborator Author

sevein commented Jun 20, 2017

I've reviewed this with @jhsimpson IRL. The issue discussed above has been captured here: #9.

See #7 and #9 for more details.

- storage_service.settings.test: disable whitenoise
- locations/fixtures/package.json: use json empty document default
- Dockerfile: add p7zip missing dependency
- Dockerfile: add workdir
- Dockerfile: add pythonpath
@sevein sevein merged commit a302168 into qa/jisc Jun 20, 2017
@sevein sevein self-assigned this Jun 20, 2017
@jhsimpson
Copy link

I did get the tests to pass. I had to do

$ docker build -t ss .

before running the docker-compose command @sevein suggested above:

$ docker run --rm --entrypoint pytest \
    --env "DJANGO_SETTINGS_MODULE=storage_service.settings.test" \
    --env "SS_DB_NAME=_" \
    --env "SS_DB_USER=_" \
    --env "SS_DB_PASSWORD=_" \
    --env "SS_DB_HOST=_" \
    --env "DJANGO_SECRET_KEY=_" \
    --env "DJANGO_ALLOWED_HOSTS=_" \
    --user "root" ss

the output was

============================= test session starts ==============================
platform linux2 -- Python 2.7.13, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
Django settings: storage_service.settings.test (from environment variable)
rootdir: /src/storage_service, inifile: pytest.ini
plugins: django-3.1.2, cov-2.4.0
collected 103 items

administration/tests/test_languages.py ....
locations/tests/test_api.py .............................
locations/tests/test_arkivum.py ......
locations/tests/test_dataverse.py ....
locations/tests/test_dspace.py .........
locations/tests/test_duracloud.py .................
locations/tests/test_fixity_log.py .
locations/tests/test_locations.py ...
locations/tests/test_lockssomatic.py .
locations/tests/test_package.py ..........
locations/tests/test_swift.py ..........
storage_service/tests/test_shibboleth.py sssss
storage_service/tests/test_startup.py ....

=============================== warnings summary ===============================
locations/tests/test_fixity_log.py::TestFixityLog::test_has_required_attributes
  /usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:1474: RuntimeWarning: DateTimeField FixityLog.datetime_reported received a naive datetime (2015-12-15 03:00:05.020871) while time zone support is active.
    RuntimeWarning)
  /usr/local/lib/python2.7/site-packages/_pytest/warnings.py:82: UnicodeWarning: Warning is using unicode non convertible to ascii, converting to a safe representation:
    /usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:1474: RuntimeWarning: DateTimeField FixityLog.datetime_reported received a naive datetime (2015-12-15 03:00:05.020871) while time zone support is active.
    RuntimeWarning)
  
    UnicodeWarning)

-- Docs: http://doc.pytest.org/en/latest/warnings.html
============== 98 passed, 5 skipped, 2 warnings in 12.12 seconds ===============

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants