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 committed Nov 19, 2024
1 parent 7e14f5b commit 78c0dd1
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ dev.shell.analyticsapi:
dev.shell.insights:
docker compose exec insights env TERM=$(TERM) bash -c 'eval $$(source /edx/app/insights/insights_env; echo PATH="$$PATH";) && /bin/bash'

dev.shell.enterprise-subsidy:
docker exec -it edx.devstack.enterprise-subsidy env TERM=$(TERM) bash -c '/bin/bash'

dev.shell.%: ## Run a shell on the specified service's container.
docker compose exec $* /bin/bash

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

if should_check enterprise-subsidy; then
echo "Running Enterprise Subsidy Devstack tests: "
run_check enterprise-subsidy_heartbeat enterprise-subsidy \
"curl --fail -L http://localhost:18280/health/"
fi

echo "Successful checks:${succeeded:- NONE}"
echo "Failed checks:${failed:- NONE}"
if [[ -z "$succeeded" ]] && [[ -z "$failed" ]]; then
Expand Down
4 changes: 4 additions & 0 deletions docker-compose-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ services:
volumes:
- ${DEVSTACK_WORKSPACE}/edx-analytics-data-api:/edx/app/analytics_api/analytics_api
- ${DEVSTACK_WORKSPACE}/src:/edx/src
enterprise-subsidy:
volumes:
- ${DEVSTACK_WORKSPACE}/enterprise-subsidy:/edx/app/enterprise-subsidy
- ${DEVSTACK_WORKSPACE}/src:/edx/src

# Note that frontends mount `src` to /edx/app/src instead of /edx/src.
# See ADR #5 for rationale.
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,28 @@ services:
aliases:
- edx.devstack.xqueue_consumer

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: enterprise001
DB_PASSWORD: password
DJANGO_SETTINGS_MODULE: enterprise_subsidy.settings.devstack
working_dir: /edx/app/enterprise-subsidy
ports:
- "18280:18280"
volumes:
- /edx/var/enterprise-subsidy

# ==========================================================================
# edX Microfrontends
#
Expand Down
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+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
analyticsapi+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

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

. scripts/colors.sh

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

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

# Create superuser
echo -e "${GREEN}Creating super-user for ${name}...${NC}"
docker exec -t edx.devstack.enterprise-subsidy 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 @@ -45,4 +45,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 'enterprise001'@'%' IDENTIFIED BY 'password';
GRANT ALL ON enterprise_subsidy.* TO 'enterprise001'@'%';

FLUSH PRIVILEGES;
1 change: 1 addition & 0 deletions provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ xqueue \
coursegraph \
insights \
analyticsapi \
enterprise-subsidy \
"

# What should we provision?
Expand Down
2 changes: 2 additions & 0 deletions repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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 @@ -78,6 +79,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 78c0dd1

Please sign in to comment.