Skip to content

Commit 4e42eed

Browse files
feat: add enterprise-access to devstack (#87)
* feat: add enterprise-access to devstack * fix: use docker compose instead of docker-compose
1 parent 7a8cfcb commit 4e42eed

File tree

11 files changed

+122
-3
lines changed

11 files changed

+122
-3
lines changed

.github/workflows/provisioning-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
os:
3131
- ubuntu-20.04 # Ubuntu 20.04 "Focal Fossa"
3232
python-version: [ '3.11' ]
33-
services: [ discovery+lms+forum ,registrar+lms, ecommerce+lms, edx_notes_api+lms, credentials+lms, xqueue, analyticsapi+insights+lms, enterprise-catalog+lms, license-manager+lms]
33+
services: [ discovery+lms+forum ,registrar+lms, ecommerce+lms, edx_notes_api+lms, credentials+lms, xqueue, analyticsapi+insights+lms, enterprise-catalog+enterprise-access+lms, license-manager+lms]
3434
fail-fast: false # some services can be flaky; let others run to completion even if one fails
3535

3636
steps:

check.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ if should_check ecommerce; then
114114
"curl --fail -L http://localhost:18130/health/"
115115
fi
116116

117+
if should_check enterprise_access; then
118+
echo "Checking enterprise-access health:"
119+
run_check enterprise_access_heartbeat enterprise-access \
120+
"curl --fail -L http://localhost:18130/health/"
121+
fi
122+
117123
if should_check discovery; then
118124
echo "Checking discovery health:"
119125
run_check discovery_heartbeat discovery \

docker-compose-host.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ services:
2020
- ecommerce_tox:/edx/app/ecommerce/ecommerce/.tox
2121
- ${DEVSTACK_WORKSPACE}/src:/edx/src
2222
- ${PWD}/py_configuration_files/ecommerce.py:/edx/app/ecommerce/ecommerce/ecommerce/settings/devstack.py
23+
enterprise-access:
24+
volumes:
25+
- ${DEVSTACK_WORKSPACE}/enterprise-access:/edx/app/enterprise-access/
26+
- ${DEVSTACK_WORKSPACE}/src:/edx/src
27+
- ${PWD}/py_configuration_files/enterprise_access.py:/edx/app/enterprise-access/license_manager/settings/devstack.py
28+
enterprise-access-worker:
29+
volumes:
30+
- ${DEVSTACK_WORKSPACE}/enterprise-access:/edx/app/enterprise-access/
2331
forum:
2432
volumes:
2533
- ${DEVSTACK_WORKSPACE}/cs_comments_service:/edx/app/forum/cs_comments_service

docker-compose.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,69 @@ services:
386386
ELASTICSEARCH_URL: "http://edx.devstack.elasticsearch710:9200"
387387
ELASTICSEARCH_DSL: "http://edx.devstack.elasticsearch710:9200"
388388

389+
enterprise-access:
390+
image: edxops/enterprise-access-dev
391+
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.enterprise-access"
392+
hostname: enterprise-access.devstack.edx
393+
command: bash -c 'while true; do python /edx/app/enterprise-access/manage.py runserver 0.0.0.0:18270; sleep 2; done'
394+
ports:
395+
- "18270:18270"
396+
depends_on:
397+
- mysql80
398+
- memcached
399+
- enterprise-access-worker
400+
networks:
401+
default:
402+
aliases:
403+
- edx.devstack.enterprise-access
404+
stdin_open: true
405+
tty: true
406+
environment:
407+
CELERY_ALWAYS_EAGER: 'false'
408+
CELERY_BROKER_TRANSPORT: redis
409+
CELERY_BROKER_HOSTNAME: edx.devstack.redis:6379
410+
CELERY_BROKER_VHOST: 0
411+
CELERY_BROKER_PASSWORD: password
412+
DJANGO_SETTINGS_MODULE: enterprise_access.settings.devstack
413+
DJANGO_WATCHMAN_TIMEOUT: 30
414+
ENABLE_DJANGO_TOOLBAR: 1
415+
DB_HOST: edx.devstack.mysql80
416+
DB_NAME: enterprise_access
417+
DB_PORT: 3306
418+
DB_USER: enterprise_access001
419+
DB_PASSWORD: password
420+
421+
enterprise-access-worker:
422+
image: edxops/enterprise-access-dev
423+
command: bash -c 'cd /edx/app/enterprise-access/ && celery -A enterprise_access worker -l DEBUG'
424+
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.enterprise-access-worker"
425+
hostname: enterprise-access-worker.devstack.edx
426+
depends_on:
427+
- mysql80
428+
- memcached
429+
environment:
430+
CELERY_ALWAYS_EAGER: 'false'
431+
CELERY_BROKER_TRANSPORT: redis
432+
CELERY_BROKER_HOSTNAME: edx.devstack.redis:6379
433+
CELERY_BROKER_VHOST: 0
434+
CELERY_BROKER_PASSWORD: password
435+
DJANGO_SETTINGS_MODULE: enterprise_access.settings.devstack
436+
COLUMNS: 80
437+
DB_HOST: edx.devstack.mysql80
438+
DB_NAME: enterprise_access
439+
DB_PORT: 3306
440+
DB_USER: enterprise_access001
441+
DB_PASSWORD: password
442+
networks:
443+
default:
444+
aliases:
445+
- edx.devstack.enterprise-access-worker
446+
ports:
447+
- "18271:18271"
448+
restart: always
449+
stdin_open: true
450+
tty: true
451+
389452
forum:
390453
command: bash -c 'source /edx/app/forum/ruby_env && source /edx/app/forum/devstack_forum_env && cd /edx/app/forum/cs_comments_service && bundle install && while true; do ./bin/unicorn -c config/unicorn_tcp.rb -I .; sleep 2; done'
391454
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.forum"

docs/service_list.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Instead of a service name or list, you can also run commands like ``make dev.pro
6969
+------------------------------------+-------------------------------------+----------------+--------------+
7070
| `enterprise-catalog`_ | http://localhost:18160/ | Python/Django | Extra |
7171
+------------------------------------+-------------------------------------+----------------+--------------+
72+
| `enterprise-access`_ | http://localhost:18270 | Python/Django | Extra |
73+
+------------------------------------+-------------------------------------+----------------+--------------+
7274

7375
Some common service combinations include:
7476

@@ -104,3 +106,4 @@ Some common service combinations include:
104106
.. _analyticsapi: https://github.com/edx/edx-analytics-data-api
105107
.. _enterprise-catalog: https://github.com/openedx/enterprise-catalog
106108
.. _license-manager: https://github.com/openedx/license-manager
109+
.. _enterprise-access: https://github.com/openedx/enterprise-access

options.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ credentials+discovery+ecommerce+edx_notes_api+forum+frontend-app-authn+frontend-
6767
# Separated by plus signs.
6868
# Separated by plus signs. Listed in alphabetical order for clarity.
6969
EDX_SERVICES ?= \
70-
analyticsapi+codejail+credentials+cms+cms-worker+cms_watcher+discovery+ecommerce+edx_notes_api+forum+frontend-app-account+frontend-app-learner-dashboard+frontend-app-learner-record+frontend-app-profile+frontend-app-authn+frontend-app-course-authoring+frontend-app-gradebook+frontend-app-ora-grading+frontend-app-learning+frontend-app-library-authoring+frontend-app-payment+frontend-app-program-console+frontend-app-publisher+insights+lms+lms-worker+lms_watcher+registrar+registrar-worker+xqueue+xqueue_consumer+enterprise-catalog+license-manager
70+
analyticsapi+codejail+credentials+cms+cms-worker+cms_watcher+discovery+ecommerce+edx_notes_api+enterprise-access+forum+frontend-app-account+frontend-app-learner-dashboard+frontend-app-learner-record+frontend-app-profile+frontend-app-authn+frontend-app-course-authoring+frontend-app-gradebook+frontend-app-ora-grading+frontend-app-learning+frontend-app-library-authoring+frontend-app-payment+frontend-app-program-console+frontend-app-publisher+insights+lms+lms-worker+lms_watcher+registrar+registrar-worker+xqueue+xqueue_consumer+enterprise-catalog+license-manager
7171

7272
# Services with database migrations.
7373
# Should be a subset of $(EDX_SERVICES).
@@ -76,7 +76,7 @@ analyticsapi+codejail+credentials+cms+cms-worker+cms_watcher+discovery+ecommerce
7676
# Note: This list should contain _all_ db-backed services, even if not
7777
# configured to run; the list will be filtered later against $(DEFAULT_SERVICES).
7878
DB_SERVICES ?= \
79-
credentials+cms+discovery+ecommerce+lms+registrar+license-manager
79+
credentials+cms+discovery+ecommerce+enterprise-access+lms+registrar+license-manager
8080

8181
# Services with static assets to be built.
8282
# Should be a subset of $(EDX_SERVICES).

provision-enterprise-access.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
set -euf -o pipefail
2+
3+
. scripts/colors.sh
4+
5+
name="enterprise-access"
6+
port="18270"
7+
8+
docker compose up -d $name lms
9+
10+
echo -e "${GREEN}Installing requirements for ${name}...${NC}"
11+
docker compose exec -T ${name} bash -e -c 'cd /edx/app/enterprise-access && make requirements' -- "$name"
12+
13+
# Run migrations
14+
echo -e "${GREEN}Running migrations for ${name}...${NC}"
15+
docker compose exec -T ${name} bash -e -c "cd /edx/app/enterprise-access/ && make migrate" -- "$name"
16+
# docker compose exec -T ${name} bash -e -c 'source /edx/app/credentials/credentials_env && cd /edx/app/credentials/credentials && make migrate' -- "$name"
17+
18+
# Create superuser
19+
echo -e "${GREEN}Creating super-user for ${name}...${NC}"
20+
docker compose exec -T ${name} bash -e -c "echo 'from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser(\"edx\", \"[email protected]\", \"edx\") if not User.objects.filter(username=\"edx\").exists() else None' | python /edx/app/enterprise-access/manage.py shell" -- "$name"
21+
22+
./provision-ida-user.sh ${name} ${name} ${port}
23+
24+
# Create system wide enterprise role assignment
25+
# TODO: this is a pretty complex oneline, we should probably eventually convert this to a management command.
26+
echo -e "${GREEN}Creating system wide enterprise user role assignment for ${name}...${NC}"
27+
docker compose exec -T lms bash -e -c "source /edx/app/edxapp/edxapp_env && echo 'from django.contrib.auth import get_user_model; from enterprise.models import SystemWideEnterpriseUserRoleAssignment, SystemWideEnterpriseRole; User = get_user_model(); worker_user = User.objects.get(username=\"${name}_worker\"); operator_role = SystemWideEnterpriseRole.objects.get(name=\"enterprise_openedx_operator\"); assignment = SystemWideEnterpriseUserRoleAssignment.objects.get_or_create(user=worker_user, role=operator_role, applies_to_all_contexts=True);' | /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py lms shell" -- lms
28+
29+
make dev.restart-devserver.enterprise-access

provision-mysql80.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ CREATE DATABASE IF NOT EXISTS ecommerce;
1818
CREATE USER IF NOT EXISTS 'ecomm001'@'%' IDENTIFIED BY 'password';
1919
GRANT ALL ON ecommerce.* TO 'ecomm001'@'%';
2020

21+
CREATE DATABASE IF NOT EXISTS enterprise_access;
22+
CREATE USER IF NOT EXISTS 'enterprise_access001'@'%' IDENTIFIED BY 'password';
23+
GRANT ALL ON enterprise_access.* TO 'enterprise_access001'@'%';
24+
2125
CREATE DATABASE IF NOT EXISTS notes;
2226
CREATE USER IF NOT EXISTS 'notes001'@'%' IDENTIFIED BY 'password';
2327
GRANT ALL ON notes.* TO 'notes001'@'%';

provision.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ insights \
5151
analyticsapi \
5252
enterprise-catalog \
5353
license-manager \
54+
enterprise-access \
5455
"
5556

5657
# What should we provision?

provision.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ GRANT ALL ON discovery.* TO 'discov001'@'%' IDENTIFIED BY 'password';
77
CREATE DATABASE IF NOT EXISTS ecommerce;
88
GRANT ALL ON ecommerce.* TO 'ecomm001'@'%' IDENTIFIED BY 'password';
99

10+
CREATE DATABASE IF NOT EXISTS enterprise_access;
11+
GRANT ALL ON enterprise_access.* TO 'enterprise_access001'@'%' IDENTIFIED BY 'password';
12+
1013
CREATE DATABASE IF NOT EXISTS notes;
1114
GRANT ALL ON notes.* TO 'notes001'@'%' IDENTIFIED BY 'password';
1215

0 commit comments

Comments
 (0)