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

Tutor integration tests #199

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fbd41fe
feat: adding an integration workflow
felipemontoya Mar 4, 2024
c0c7f74
feat: running tutor
felipemontoya Mar 4, 2024
2f69aa5
feat: run commands
felipemontoya Mar 4, 2024
ef56e8e
feat: running dev mode
felipemontoya Mar 4, 2024
650adfd
feat: installing in dev mode
felipemontoya Mar 4, 2024
8934a93
feat: using bind mounts
felipemontoya Mar 4, 2024
2d6ad1e
feat: explicit mount
felipemontoya Mar 5, 2024
ab3aea1
feat: running during same step
felipemontoya Mar 5, 2024
f56217f
feat: using exec for install
felipemontoya Mar 5, 2024
1e1656f
feat: back to run
felipemontoya Mar 5, 2024
ede3045
fix: all local no dev
felipemontoya Mar 5, 2024
98e28eb
fix: permissions
felipemontoya Mar 5, 2024
780240f
fix: sharing the parent dir
felipemontoya Mar 5, 2024
d5e5fe5
fix: permissions
felipemontoya Mar 5, 2024
8f039d1
fix: 777 using chmod
felipemontoya Mar 5, 2024
0d5cbc6
fix: running a second step
felipemontoya Mar 5, 2024
6ff2c28
feat: trying a bash script
felipemontoya Mar 7, 2024
9ca8bdc
feat: using a integration tutor as the make target
felipemontoya Mar 7, 2024
1d12b8c
feat: moving to bare dir without src
felipemontoya Mar 7, 2024
6c96dc0
fix: tutor mounts path
felipemontoya Mar 7, 2024
959c343
fix: find paths
felipemontoya Mar 7, 2024
e4fbb7c
fix: setting up the databases correctly
felipemontoya Mar 8, 2024
9a8142d
feat: making actual tests that import openedx code run
felipemontoya Mar 8, 2024
3fe2ab2
feat: ignoring warning to avoid unnecessary noise during initial stages
felipemontoya Mar 8, 2024
3f32345
fix: using explicit mounts
felipemontoya Mar 8, 2024
868d53d
feat: running command check and migrations
felipemontoya Mar 8, 2024
662d84c
feat: better comments in script
felipemontoya Mar 8, 2024
2a5ee17
test: launching in previous step
felipemontoya Mar 8, 2024
eb40e5f
feat: using matrix for tutor version
felipemontoya Mar 8, 2024
9869efd
fix: limiting to q and p
felipemontoya Mar 8, 2024
fcab6f4
fix: better names for steps
felipemontoya Mar 8, 2024
81a8b56
chore: update dependencies
felipemontoya Mar 8, 2024
3270b7c
fix: making integration tests not part of regular test discovery
felipemontoya Mar 8, 2024
07585d8
fix: addressing quality alerts
felipemontoya Mar 8, 2024
15698bf
fix: skipping isort inside the test
felipemontoya Mar 8, 2024
ae80464
feat: adding tutor nightly workflow
felipemontoya Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Integration Tests Quince, Palm

on:
push:
branches:
- 'fmo/**'

jobs:
edx-platform-integration-test:
name: Integration with Tutor
strategy:
matrix: # quince palm olive
# tutor_version: ["<18.0.0", "<17.0.0", "<16.0.0"]
tutor_version: ["<18.0.0", "<17.0.0"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: eox-tenant

- name: Prepare Tutor & launch
run: |
pip install "tutor${{ matrix.tutor_version }}"
TUTOR_ROOT="$(pwd)" tutor --version
TUTOR_ROOT="$(pwd)" tutor config save
TUTOR_ROOT="$(pwd)" tutor mounts add lms,cms,lms-worker,cms-worker:$(pwd)/eox-tenant:/openedx/eox-tenant
chmod 777 . -R
TUTOR_ROOT="$(pwd)" tutor local launch -I

- name: Run integration tests in lms
run: |
TUTOR_ROOT="$(pwd)" tutor local run lms bash /openedx/eox-tenant/eox_tenant/test/tutor/integration.sh
45 changes: 45 additions & 0 deletions .github/workflows/integration_tutor_nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Integration Tests with openedx.master

on:
push:
branches:
- 'fmo/**'

jobs:
edx-platform-integration-test:
name: Integration with Tutor nightly
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: eox-tenant

- name: Get Tutor
run: |
pip install virtualenv
virtualenv venv
source venv/bin/activate
git clone --branch=nightly --depth=1 https://github.com/overhangio/tutor.git
chmod 777 tutor -R
pip install -e "./tutor[full]"

- name: Prepare Tutor
run: |
source venv/bin/activate
TUTOR_ROOT="$(pwd)" tutor --version
TUTOR_ROOT="$(pwd)" tutor config save
TUTOR_ROOT="$(pwd)" tutor plugins disable mfe
TUTOR_ROOT="$(pwd)" tutor mounts add lms,cms,lms-worker,cms-worker:$(pwd)/eox-tenant:/openedx/eox-tenant
chmod 777 . -R
TUTOR_ROOT="$(pwd)" tutor images build openedx # ~11 min

- name: Launch Tutor
run: |
source venv/bin/activate
TUTOR_ROOT="$(pwd)" tutor local launch -I

- name: Run integration tests in lms
run: |
source venv/bin/activate
TUTOR_ROOT="$(pwd)" tutor local run lms bash /openedx/eox-tenant/eox_tenant/test/tutor/integration.sh
10 changes: 10 additions & 0 deletions eox_tenant/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"""
from __future__ import absolute_import, unicode_literals

import codecs
import os

import yaml

from .common import * # pylint: disable=wildcard-import,unused-wildcard-import


Expand Down Expand Up @@ -90,3 +95,8 @@ def plugin_settings(settings): # pylint: disable=function-redefined
settings.OAUTH2_PROVIDER['OAUTH2_VALIDATOR_CLASS'] = (
'openedx.core.djangoapps.oauth_dispatch.dot_overrides.validators.EdxOAuth2Validator'
)

# setup the databases used in the tutor local environment
with codecs.open(os.environ['LMS_CFG'], encoding='utf-8') as f:
env_tokens = yaml.safe_load(f)
settings.DATABASES = env_tokens['DATABASES']
3 changes: 1 addition & 2 deletions eox_tenant/tenant_aware_functions/enrollments.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def filter_enrollments(enrollments):
# If test setting is true, returns the same enrollments,
# or if we do not have a microsite context, there is nothing we can do.
if test_skip or not theming_helpers.is_request_in_themed_site():
for enrollment in enrollments:
yield enrollment
yield from enrollments
return

configuration_helpers = get_configuration_helpers()
Expand Down
Empty file.
16 changes: 16 additions & 0 deletions eox_tenant/test/tutor/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
The conftest module sets up the database connection for pytest-django.

The integration tests will reuse the database from tutor local so a noop
django_db_setup is required.
See: https://pytest-django.readthedocs.io/en/latest/database.html
"""

import pytest # pylint: disable=import-error


@pytest.fixture(scope='session')
def django_db_setup():
"""
Makes the tests reuse the existing database
"""
25 changes: 25 additions & 0 deletions eox_tenant/test/tutor/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# install the package in the edxapp env
echo "Install package"
pip install -e ../eox-tenant

# test that the commands for eox-tenant are being listed at the lms
echo "Tests django commands"
is_command_installed=$(./manage.py lms help | grep eox | wc -l)
if [ $is_command_installed == 0 ] ; then
echo 'package was not installed correctly'
exit -1;
fi

# run migrations
echo "Run migrations"
./manage.py lms migrate eox_tenant

# install pytest
echo "Install test-requirements"
make test-requirements

# running the tests using the tutor settings
echo "Install test-requirements"
pytest -s --ds=lms.envs.tutor.test /openedx/eox-tenant/eox_tenant/test/tutor
35 changes: 35 additions & 0 deletions eox_tenant/test/tutor/integration_test_tutor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Test views file.
"""
from django.test import TestCase


class TutorIntegrationTestCase(TestCase):
"""
POC code to run tests that cover the integration with openedx
"""

def test_runs_code(self):
"""
Just to make sure our test infrastructure is behaving
"""
assert True

# pylint: disable=import-outside-toplevel,unused-import
def test_current_settings_code_imports(self):
"""
Running this imports means that our backends import the right signature
"""
import eox_tenant.edxapp_wrapper.backends.oauth_dispatch_j_v1 # isort:skip
import eox_tenant.edxapp_wrapper.backends.branding_api_l_v1 # isort:skip
# fixme: needs to be properly removed if unused at the latest version # pylint: disable=fixme
# import eox_tenant.edxapp_wrapper.backends.certificates_module_i_v1
import eox_tenant.edxapp_wrapper.backends.site_configuration_module_i_v1 # isort:skip
import eox_tenant.edxapp_wrapper.backends.theming_helpers_h_v1 # isort:skip
# fixme: needs to be properly removed if unused at the latest version # pylint: disable=fixme
# import eox_tenant.edxapp_wrapper.backends.edx_auth_i_v1
import eox_tenant.edxapp_wrapper.backends.users_l_v1 # isort:skip
import eox_tenant.edxapp_wrapper.backends.bearer_authentication_l_v1 # isort:skip
import eox_tenant.edxapp_wrapper.backends.edxmako_l_v1 # isort:skip
# fixme: needs to be properly removed if unused at the latest version # pylint: disable=fixme
# import eox_tenant.edxapp_wrapper.backends.util_h_v1 # fixme
7 changes: 7 additions & 0 deletions eox_tenant/test/tutor/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
python_files = integration_test_*.py
filterwarnings =
default
# We ignore every warning while we actually get the testing infrastructure
# running for different version of tutor in gh actions
ignore:
6 changes: 3 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ asgiref==3.7.2
# via django
backports-zoneinfo==0.2.1
# via django
django==4.2.10
django==4.2.11
# via
# -c requirements/constraints.txt
# -r requirements/base.in
Expand Down Expand Up @@ -39,9 +39,9 @@ six==1.16.0
# via -r requirements/base.in
sqlparse==0.4.4
# via django
stevedore==5.1.0
stevedore==5.2.0
# via edx-opaque-keys
typing-extensions==4.9.0
typing-extensions==4.10.0
# via
# asgiref
# edx-opaque-keys
2 changes: 1 addition & 1 deletion requirements/django42.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django==4.2.10
django==4.2.11
10 changes: 6 additions & 4 deletions requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
#
# make upgrade
#
build==1.0.3
build==1.1.1
# via pip-tools
click==8.1.7
# via pip-tools
importlib-metadata==7.0.1
importlib-metadata==7.0.2
# via build
packaging==23.2
# via build
pip-tools==7.3.0
pip-tools==7.4.1
# via -r requirements/pip-tools.in
pyproject-hooks==1.0.0
# via build
# via
# build
# pip-tools
tomli==2.0.1
# via
# build
Expand Down
1 change: 1 addition & 0 deletions requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ coverage
mock
testfixtures
path.py
pyyaml
22 changes: 11 additions & 11 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ asgiref==3.7.2
# via
# -r requirements/base.txt
# django
astroid==3.0.3
astroid==3.1.0
# via pylint
backports-zoneinfo==0.2.1
# via
# -r requirements/base.txt
# django
coverage==7.4.1
coverage==7.4.3
# via -r requirements/test.in
ddt==1.7.1
ddt==1.7.2
# via -r requirements/test.in
dill==0.3.8
# via pylint
Expand All @@ -37,9 +37,7 @@ django-mysql==4.12.0
djangorestframework==3.14.0
# via -r requirements/base.txt
edx-opaque-keys[django]==2.5.1
# via
# -r requirements/base.txt
# edx-opaque-keys
# via -r requirements/base.txt
isort==5.13.2
# via pylint
jsonfield==3.1.0
Expand All @@ -62,7 +60,7 @@ platformdirs==4.2.0
# via pylint
pycodestyle==2.11.1
# via -r requirements/test.in
pylint==3.0.3
pylint==3.1.0
# via -r requirements/test.in
pymongo==3.13.0
# via
Expand All @@ -72,23 +70,25 @@ pytz==2024.1
# via
# -r requirements/base.txt
# djangorestframework
pyyaml==6.0.1
# via -r requirements/test.in
six==1.16.0
# via -r requirements/base.txt
sqlparse==0.4.4
# via
# -r requirements/base.txt
# django
stevedore==5.1.0
stevedore==5.2.0
# via
# -r requirements/base.txt
# edx-opaque-keys
testfixtures==7.2.2
testfixtures==8.1.0
# via -r requirements/test.in
tomli==2.0.1
# via pylint
tomlkit==0.12.3
tomlkit==0.12.4
# via pylint
typing-extensions==4.9.0
typing-extensions==4.10.0
# via
# -r requirements/base.txt
# asgiref
Expand Down
6 changes: 3 additions & 3 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
cachetools==5.3.2
cachetools==5.3.3
# via tox
chardet==5.2.0
# via tox
Expand Down Expand Up @@ -32,7 +32,7 @@ tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.12.1
tox==4.14.1
# via -r requirements/tox.in
virtualenv==20.25.0
virtualenv==20.25.1
# via tox
Loading