Skip to content

Commit

Permalink
feat: Add enterprise subsidy service to Devstack
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarhan943 authored and iamsobanjaved committed Feb 18, 2025
1 parent 2960ad3 commit 0eb6bd9
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/provisioning-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
os:
- ubuntu-20.04 # Ubuntu 20.04 "Focal Fossa"
python-version: [ '3.11' ]
services: [ discovery+lms+forum ,registrar+lms, ecommerce+lms, edx_notes_api+lms, credentials+lms, xqueue, analyticsapi+insights+lms, designer+lms, enterprise-catalog+enterprise-access+lms, license-manager+lms]
services: [ discovery+lms+forum ,registrar+lms, ecommerce+lms, edx_notes_api+lms, credentials+lms, xqueue, analyticsapi+insights+lms, designer+lms, enterprise-subsidy+enterprise-catalog+enterprise-access+lms, license-manager+lms]
fail-fast: false # some services can be flaky; let others run to completion even if one fails

steps:
Expand Down
6 changes: 6 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ if should_check enterprise_access; then
"curl --fail -L http://localhost:18130/health/"
fi

if should_check enterprise-subsidy; then
echo "Checking enterprise-subsidy health:"
run_check enterprise_subsidy_heartbeat enterprise-subsidy \
"curl --fail -L http://localhost:18280/health/"
fi

if should_check discovery; then
echo "Checking discovery health:"
run_check discovery_heartbeat discovery \
Expand Down
11 changes: 9 additions & 2 deletions docker-compose-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ services:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-access:/edx/app/enterprise-access/
- ${DEVSTACK_WORKSPACE}/src:/edx/src
- ${PWD}/py_configuration_files/enterprise_access.py:/edx/app/enterprise-access/license_manager/settings/devstack.py
enterprise-access-worker:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-access:/edx/app/enterprise-access/
Expand Down Expand Up @@ -88,9 +87,16 @@ services:
- ${DEVSTACK_WORKSPACE}/edx-analytics-data-api:/edx/app/analytics_api/analytics_api
- ${DEVSTACK_WORKSPACE}/src:/edx/src
- ${PWD}/py_configuration_files/analytics_data_api.py:/edx/app/analytics_api/analytics_api/analyticsdataserver/settings/devstack.py
enterprise-subsidy:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-subsidy:/edx/app/enterprise-subsidy
- ${DEVSTACK_WORKSPACE}/src:/edx/src
- ${PWD}/py_configuration_files/enterprise_subsidy.py:/edx/app/enterprise-subsidy/enterprise_subsidy/settings/devstack.py

enterprise-catalog:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-catalog:/edx/app/enterprise_catalog/enterprise_catalog
- ${PWD}/py_configuration_files/enterprise_catalog.py:/edx/app/enterprise_catalog/enterprise_catalog/settings/devstack.py
enterprise-catalog-worker:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-catalog:/edx/app/enterprise_catalog/enterprise_catalog
Expand All @@ -112,7 +118,8 @@ services:
volumes:
- ${DEVSTACK_WORKSPACE}/license-manager:/edx/app/license_manager
- ${DEVSTACK_WORKSPACE}/src:/edx/src:cached
- ${PWD}/py_configuration_files/license_manager.py:/edx/app/license_manager/license_manager/settings/devstack.py
- ${PWD}/py_configuration_files/license_manager.py:/edx/app/license_manager/license_manager/settings/devstack.py

# Note that frontends mount `src` to /edx/app/src instead of /edx/src.
# See ADR #5 for rationale.
frontend-app-account:
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,29 @@ services:
stdin_open: true
tty: true

enterprise-subsidy:
image: edxops/enterprise-subsidy-dev
container_name: edx.devstack.enterprise-subsidy
hostname: enterprise-subsidy.devstack.edx
depends_on:
- mysql80
- memcached
command: bash -c 'while true; do python /edx/app/enterprise-subsidy/manage.py runserver 0.0.0.0:18280; sleep 2; done'
stdin_open: true
tty: true
environment:
DB_HOST: edx.devstack.mysql80
DB_PORT: 3306
DB_USER: subsidy001
DB_PASSWORD: password
DJANGO_SETTINGS_MODULE: enterprise_subsidy.settings.devstack
MEMCACHE_HOST: memcached.devstack.edx:11211
working_dir: /edx/app/enterprise-subsidy
ports:
- "18280:18280"
volumes:
- /edx/var/enterprise-subsidy

# ==========================================================================
# edX Microfrontends
#
Expand Down
3 changes: 3 additions & 0 deletions docs/service_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Instead of a service name or list, you can also run commands like ``make dev.pro
+------------------------------------+-------------------------------------+----------------+--------------+
| `enterprise-access`_ | http://localhost:18270 | Python/Django | Extra |
+------------------------------------+-------------------------------------+----------------+--------------+
| `enterprise-subsidy`_ | http://localhost:18280 | Python/Django | Extra |
+------------------------------------+-------------------------------------+----------------+--------------+

Some common service combinations include:

Expand Down Expand Up @@ -110,3 +112,4 @@ Some common service combinations include:
.. _enterprise-catalog: https://github.com/openedx/enterprise-catalog
.. _license-manager: https://github.com/openedx/license-manager
.. _enterprise-access: https://github.com/openedx/enterprise-access
.. _enterprise-subsidy: https://github.com/openedx/enterprise-subsidy
2 changes: 1 addition & 1 deletion options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ credentials+discovery+ecommerce+edx_notes_api+forum+frontend-app-authn+frontend-
# Separated by plus signs.
# Separated by plus signs. Listed in alphabetical order for clarity.
EDX_SERVICES ?= \
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+designer+enterprise-access
analyticsapi+codejail+enterprise-subsidy+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+designer+enterprise-access

# Services with database migrations.
# Should be a subset of $(EDX_SERVICES).
Expand Down
24 changes: 24 additions & 0 deletions provision-enterprise-subsidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -eu -o pipefail
set -x

. scripts/colors.sh

name="enterprise-subsidy"
port="18280"

docker compose up -d lms
docker compose up -d ${name}

# Run migrations
echo -e "${GREEN}Running migrations for ${name}...${NC}"
docker compose exec ${name} bash -c "cd /edx/app/${name}/ && make migrate"

# Create superuser
echo -e "${GREEN}Creating super-user for ${name}...${NC}"
docker compose exec ${name} bash -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/${name}/manage.py shell"

# Provision IDA User in LMS
echo -e "${GREEN}Provisioning ${name}_worker in LMS...${NC}"

./provision-ida-user.sh ${name} ${name} ${port}
4 changes: 4 additions & 0 deletions provision-mysql80.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ CREATE USER IF NOT EXISTS 'edxapp001'@'%' IDENTIFIED BY 'password';
GRANT ALL ON edxapp.* TO 'edxapp001'@'%';
GRANT ALL ON edxapp_csmh.* TO 'edxapp001'@'%';

CREATE DATABASE IF NOT EXISTS enterprise_subsidy;
CREATE USER IF NOT EXISTS 'subsidy001'@'%' IDENTIFIED BY 'password';
GRANT ALL ON enterprise_subsidy.* TO 'subsidy001'@'%';

FLUSH PRIVILEGES;
1 change: 1 addition & 0 deletions provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enterprise-catalog \
license-manager \
designer \
enterprise-access \
enterprise-subsidy \
"

# What should we provision?
Expand Down
4 changes: 4 additions & 0 deletions provision.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ GRANT ALL ON `reports`.* TO 'analytics001'@'%' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS `reports_v1`;
GRANT ALL ON `reports_v1`.* TO 'analytics001'@'%' IDENTIFIED BY 'password';

CREATE DATABASE IF NOT EXISTS enterprise_subsidy;
CREATE USER IF NOT EXISTS 'subsidy001'@'%' IDENTIFIED BY 'password';
GRANT ALL ON enterprise_subsidy.* TO 'subsidy001'@'%';

CREATE DATABASE IF NOT EXISTS `enterprise_catalog`;
GRANT ALL ON `enterprise_catalog`.* TO 'catalog001'@'%' IDENTIFIED BY 'password';

Expand Down
2 changes: 2 additions & 0 deletions repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ non_release_repos=(
"https://github.com/openedx/frontend-app-account.git"
"https://github.com/openedx/frontend-app-profile.git"
"https://github.com/openedx/frontend-app-ora-grading.git"
"https://github.com/openedx/enterprise-subsidy.git"
)

ssh_repos=(
Expand Down Expand Up @@ -88,6 +89,7 @@ non_release_ssh_repos=(
"[email protected]:openedx/frontend-app-account.git"
"[email protected]:openedx/frontend-app-profile.git"
"[email protected]:openedx/frontend-app-ora-grading.git"
"[email protected]:openedx/enterprise-subsidy.git"
)

if [ -n "${OPENEDX_RELEASE}" ]; then
Expand Down

0 comments on commit 0eb6bd9

Please sign in to comment.