Skip to content

Commit 57a5166

Browse files
committed
Simplify handling of Analytics Pipeline and Marketing
* Allow analytics pipeline to be provisioned and run just like other services. * Test marketing site in its own shard. * Allow marketing site to be provisioned and run just like other services. * Clean up redundant Makefile rules a bit. * Fix quality issues in provision.sh with shellcheck==0.7.0.
1 parent ace4173 commit 57a5166

7 files changed

+77
-96
lines changed

.travis.yml

+11-14
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ branches:
1010
- master
1111

1212
env:
13-
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 DEVSTACK='lms'
14-
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 DEVSTACK='registrar'
15-
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 DEVSTACK='ecommerce'
16-
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 DEVSTACK='edx_notes_api'
17-
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 DEVSTACK='credentials'
18-
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 DEVSTACK='analytics_pipeline'
13+
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 SERVICES='lms+discovery+forum'
14+
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 SERVICES='lms+registrar'
15+
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 SERVICES='ecommerce'
16+
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 SERVICES='edx_notes_api'
17+
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 SERVICES='credentials'
18+
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 SERVICES='analyticspipeline'
19+
- DEVSTACK_WORKSPACE=/tmp SHALLOW_CLONE=1 SERVICES='marketing'
1920

2021
services:
2122
- docker
@@ -27,15 +28,11 @@ before_install:
2728
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
2829
- docker version
2930
- docker-compose --version
30-
3131
- make requirements
3232
- make dev.clone
33-
- |
34-
if [[ $DEVSTACK == 'analytics_pipeline' ]]; then
35-
make dev.up.analytics_pipeline
36-
else
37-
make dev.pull.${DEVSTACK}
38-
fi
33+
- make dev.pull."$SERVICES"
3934

4035
script:
41-
- "./.travis/run.sh"
36+
- make dev.provision.services."$SERVICES"
37+
- make dev.up."$SERVICES"
38+
- make dev.check."$SERVICES"

.travis/run.sh

-29
This file was deleted.

Makefile

+26-31
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@
66
########################################################################################################################
77
.DEFAULT_GOAL := help
88

9-
.PHONY: analytics-pipeline-devstack-test analytics-pipeline-shell backup \
10-
build-courses check-memory create-test-course credentials-shell \
11-
destroy dev.cache-programs dev.checkout dev.clone dev.clone.ssh \
12-
dev.nfs.provision dev.nfs.provision.services dev.nfs.setup dev.nfs.up \
13-
dev.nfs.up.all dev.nfs.up.watchers devpi-password dev.provision \
14-
dev.provision.analytics_pipeline dev.provision.analytics_pipeline.run \
15-
dev.provision.services dev.provision.xqueue dev.provision.xqueue.run \
16-
dev.pull dev.repo.reset dev.reset dev.status dev.sync.daemon.start \
17-
dev.sync.provision dev.sync.requirements dev.sync.up dev.up dev.up.all \
9+
.PHONY: analytics-pipeline-devstack-test analytics-pipeline-shell \
10+
analyticspipeline-shell backup build-courses check-memory \
11+
create-test-course credentials-shell destroy dev.cache-programs \
12+
dev.checkout dev.clone dev.clone.ssh dev.nfs.provision \
13+
dev.nfs.provision.services dev.nfs.setup dev.nfs.up dev.nfs.up.all \
14+
dev.nfs.up.watchers devpi-password dev.provision \
15+
dev.provision.analytics_pipeline dev.provision.services \
16+
dev.provision.xqueue dev.provision.xqueue.run dev.pull dev.repo.reset \
17+
dev.reset dev.status dev.sync.daemon.start dev.sync.provision \
18+
dev.sync.requirements dev.sync.up dev.up dev.up.all \
1819
dev.up.analytics_pipeline dev.up.watchers dev.up.with-programs \
1920
dev.up.xqueue discovery-shell down e2e-shell e2e-tests ecommerce-shell \
2021
feature-toggle-state forum-restart-devserver healthchecks help lms-restart \
2122
lms-shell lms-static lms-update-db lms-watcher-shell logs mongo-shell \
2223
mysql-shell mysql-shell-edxapp provision pull pull.analytics_pipeline \
23-
pull.xqueue registrar-shell requirements restore static stats stop \
24-
stop.all stop.analytics_pipeline stop.watchers stop.xqueue \
24+
pull.xqueue registrar-shell requirements restore selfcheck static \
25+
stats stop stop.all stop.analytics_pipeline stop.watchers stop.xqueue \
2526
studio-restart studio-shell studio-static studio-update-db \
2627
studio-watcher-shell update-db upgrade upgrade validate \
2728
validate-lms-volume vnc-passwords xqueue_consumer-logs \
@@ -113,7 +114,7 @@ dev.provision.services: ## Provision all services with local mounted directories
113114
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_SUITE)" $(WINPTY) bash ./provision.sh
114115

115116
dev.provision.services.%: ## Provision specified services with local mounted directories, separated by plus signs
116-
DOCKER_COMPOSE_FILES="$(STANDARD_COMPOSE_SUITE)" $(WINPTY) bash ./provision.sh $*
117+
DOCKER_COMPOSE_FILES="$(FULL_COMPOSE_SUITE)" $(WINPTY) bash ./provision.sh $*
117118

118119
dev.provision: | check-memory dev.clone.ssh dev.provision.services stop ## Provision dev environment with all services stopped
119120

@@ -149,7 +150,7 @@ ifeq ($(ALWAYS_CACHE_PROGRAMS),true)
149150
endif
150151

151152
dev.up.%: | check-memory ## Bring up specific services (separated by plus-signs) and their dependencies with host volumes.
152-
bash -c 'docker-compose $(STANDARD_COMPOSE_SUITE) up -d $$(echo $* | tr + " ")'
153+
bash -c 'docker-compose $(FULL_COMPOSE_SUITE) up -d $$(echo $* | tr + " ")'
153154
ifeq ($(ALWAYS_CACHE_PROGRAMS),true)
154155
make dev.cache-programs
155156
endif
@@ -198,6 +199,9 @@ dev.sync.requirements: ## Install requirements
198199
dev.sync.up: dev.sync.daemon.start ## Bring up all services with docker-sync enabled
199200
docker-compose $(STANDARD_COMPOSE_SUITE_FOR_SYNC) up -d
200201

202+
dev.check.%: # Run checks for a given service or set of services (separated by plus-signs).
203+
$(WINPTY) bash ./check.sh $*
204+
201205
provision: | dev.provision ## This command will be deprecated in a future release, use dev.provision
202206
echo "\033[0;31mThis command will be deprecated in a future release, use dev.provision\033[0m"
203207

@@ -288,6 +292,9 @@ restore: dev.up.mysql+mongo+elasticsearch ## Restore all data volumes from the h
288292
%-shell: ## Run a shell on the specified service container
289293
docker exec -it edx.devstack.$* /bin/bash
290294

295+
analyticspipeline-shell: ## Run a shell on the analytics pipeline container
296+
docker exec -it edx.devstack.analytics_pipeline env TERM=$(TERM) /edx/app/analytics_pipeline/devstack.sh open
297+
291298
credentials-shell: ## Run a shell on the credentials container
292299
docker exec -it edx.devstack.credentials env TERM=$(TERM) bash -c 'source /edx/app/credentials/credentials_env && cd /edx/app/credentials/credentials && /bin/bash'
293300

@@ -361,11 +368,9 @@ studio-static: ## Rebuild static assets for the Studio container
361368

362369
static: | credentials-static discovery-static ecommerce-static lms-static studio-static ## Rebuild static assets for all service containers
363370

364-
healthchecks: ## Run a curl against all services' healthcheck endpoints to make sure they are up. This will eventually be parameterized
365-
$(WINPTY) bash ./check.sh all
371+
healthchecks: dev.check.registrar+lms+ecommerce+discovery+forum+edx_notes_api+credentials
366372

367-
healthchecks.%:
368-
$(WINPTY) bash ./check.sh $*
373+
healthchecks.%: dev.check.%
369374

370375
e2e-tests: ## Run the end-to-end tests against the service containers
371376
docker run -t --network=devstack_default -v ${DEVSTACK_WORKSPACE}/edx-e2e-tests:/edx-e2e-tests -v ${DEVSTACK_WORKSPACE}/edx-platform:/edx-e2e-tests/lib/edx-platform --env-file ${DEVSTACK_WORKSPACE}/edx-e2e-tests/devstack_env edxops/e2e env TERM=$(TERM) bash -c 'paver e2e_test --exclude="whitelabel\|enterprise"'
@@ -391,23 +396,13 @@ mysql-shell-edxapp: ## Run a mysql shell on the edxapp database
391396
mongo-shell: ## Run a shell on the mongo container
392397
docker-compose exec mongo bash
393398

394-
### analytics pipeline commands
399+
dev.provision.analytics_pipeline: dev.provision.services.analyticspipeline
395400

401+
analytics-pipeline-shell: analyticspipeline-shell
396402

397-
dev.provision.analytics_pipeline: | check-memory dev.provision.analytics_pipeline.run stop.analytics_pipeline stop ## Provision analyticstack dev environment with all services stopped
398-
echo "Ran dev.provision.analytics_pipeline"
399-
400-
dev.provision.analytics_pipeline.run:
401-
DOCKER_COMPOSE_FILES="$(ANALYTICS_COMPOSE_SUITE)" ./provision-analytics-pipeline.sh
402-
403-
analytics-pipeline-shell: ## Run a shell on the analytics pipeline container
404-
docker exec -it edx.devstack.analytics_pipeline env TERM=$(TERM) /edx/app/analytics_pipeline/devstack.sh open
405-
406-
dev.up.analytics_pipeline: | check-memory ## Bring up analytics pipeline services
407-
bash -c 'docker-compose $(ANALYTICS_COMPOSE_SUITE) up -d analyticspipeline'
403+
dev.up.analytics_pipeline: dev.up.analyticspipeline ## Bring up analytics pipeline services
408404

409-
pull.analytics_pipeline: ## Update analytics pipeline docker images
410-
docker-compose $(ANALYTICS_COMPOSE_SUITE) pull
405+
pull.analytics_pipeline: dev.pull.analyticspipeline ## Update analytics pipeline docker images
411406

412407
analytics-pipeline-devstack-test: ## Run analytics pipeline tests in travis build
413408
docker exec -u hadoop -i edx.devstack.analytics_pipeline bash -c 'sudo chown -R hadoop:hadoop /edx/app/analytics_pipeline && source /edx/app/hadoop/.bashrc && make develop-local && make docker-test-acceptance-local ONLY_TESTS=edx.analytics.tasks.tests.acceptance.test_internal_reporting_database && make docker-test-acceptance-local ONLY_TESTS=edx.analytics.tasks.tests.acceptance.test_user_activity'

check.sh

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ if should_check credentials; then
105105
"curl --fail -L http://localhost:18150/health"
106106
fi
107107

108+
if should_check marketing; then
109+
echo "Seeing if we can curl root of Marketing site: "
110+
run_check marketing_curl marketing \
111+
"curl http://localhost:8080"
112+
fi
113+
108114
echo "Successful checks:${succeeded:- NONE}"
109115
echo "Failed checks:${failed:- NONE}"
110116
if [[ "$succeeded" ]]; then

provision-analytics-pipeline.sh renamed to provision-analyticspipeline.sh

+2-18
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,8 @@ elif [ ! -d "$DEVSTACK_WORKSPACE" ]; then
1616
exit 1
1717
fi
1818

19-
# Bring the mysql & pipeline containers online.
20-
docker-compose $DOCKER_COMPOSE_FILES up -d mysql analyticspipeline
21-
22-
# Ensure the MySQL server is online and usable
23-
echo "Waiting for MySQL"
24-
until docker exec -i edx.devstack.mysql mysql -uroot -se "SELECT EXISTS(SELECT 1 FROM mysql.user WHERE user = 'root')" &> /dev/null
25-
do
26-
printf "."
27-
sleep 1
28-
done
29-
30-
# In the event of a fresh MySQL container, wait a few seconds for the server to restart.
31-
# This can be removed once https://github.com/docker-library/mysql/issues/245 is resolved.
32-
sleep 20
19+
# Bring the pipeline containers online.
20+
docker-compose $DOCKER_COMPOSE_FILES up -d analyticspipeline
3321

3422
# Analytics pipeline has dependency on lms but we only need its db schema & not full lms. So we'll just load their db
3523
# schemas as part of analytics pipeline provisioning. If there is a need of a fully fledged LMS, then provision lms
@@ -69,7 +57,3 @@ sleep 10 # for datanode & other services to activate
6957
echo -e "${GREEN}Namenode is ready!${NC}"
7058

7159
docker exec -u hadoop -i edx.devstack.analytics_pipeline bash -c 'sudo /edx/app/hadoop/hadoop/bin/hdfs dfs -chown -R hadoop:hadoop hdfs://namenode:8020/; hdfs dfs -mkdir -p hdfs://namenode:8020/edx-analytics-pipeline/{warehouse,marker,manifest,packages} hdfs://namenode:8020/{spark-warehouse,data} hdfs://namenode:8020/tmp/spark-events;hdfs dfs -copyFromLocal -f /edx/app/hadoop/lib/edx-analytics-hadoop-util.jar hdfs://namenode:8020/edx-analytics-pipeline/packages/;'
72-
73-
docker image prune -f
74-
75-
echo -e "${GREEN}Analytics pipeline provisioning complete!${NC}"

provision-marketing.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -o pipefail
5+
set -x
6+
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m' # No Color
9+
10+
docker-compose $DOCKER_COMPOSE_FILES up -d marketing
11+
12+
set +x
13+
echo -e "${YELLOW}edX Marketing Site is not fully provisioned yet.${NC}"
14+
echo -e "${YELLOW}For full setup, see:${NC}"
15+
echo -e "${YELLOW} https://openedx.atlassian.net/wiki/spaces/ENG/pages/159162183/Marketing+Site${NC}"
16+
set -x

provision.sh

+16-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
set -e
3030
set -o pipefail
31+
set -u
3132
set -x
3233

3334
RED='\033[0;31m'
@@ -37,13 +38,24 @@ NC='\033[0m' # No Color
3738

3839
# All provisionable services.
3940
# Note: leading and trailing space are necessary for if-checks.
40-
ALL_SERVICES=" lms ecommerce discovery credentials e2e forum notes registrar "
41+
ALL_SERVICES=" \
42+
lms \
43+
ecommerce \
44+
discovery \
45+
credentials \
46+
e2e \
47+
forum \
48+
notes \
49+
registrar \
50+
analyticspipeline \
51+
marketing \
52+
"
4153

4254
# What should we provision?
4355
if [[ $# -eq 0 ]]; then
4456
requested_services=$ALL_SERVICES
4557
else
46-
arg_string=" $@ "
58+
arg_string=" $* "
4759
# Replace plus signs with spaces in order to allow plus-sign-separated
4860
# services in addition to space-separated services.
4961
requested_services="${arg_string//+/ }"
@@ -53,7 +65,7 @@ fi
5365
is_substring() {
5466
local str="$1"
5567
local substr="$2"
56-
if [[ "$1" == *" ${2} "* ]]; then
68+
if [[ "$str" == *" ${substr} "* ]]; then
5769
return 0 # Note that '0' means 'success' (i.e., true) in bash.
5870
else
5971
return 1
@@ -145,7 +157,7 @@ fi
145157
# Run the service-specific provisioning script(s)
146158
for service in $to_provision; do
147159
echo -e "${GREEN} Provisioning ${service}...${NC}"
148-
./provision-${service}.sh
160+
./provision-"$service".sh
149161
echo -e "${GREEN} Provisioned ${service}.${NC}"
150162
done
151163

0 commit comments

Comments
 (0)