Skip to content

Commit

Permalink
👷(project) test production builds
Browse files Browse the repository at this point in the history
To ensure that our production builds are able to start and respond with
a HTTP requests we now start the CMS & LMS production services using
docker-compose and use curl to test them.
  • Loading branch information
jmaupetit committed Sep 6, 2019
1 parent c3138fc commit ac01898
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@ build_steps: &build_steps
source releases/${CIRCLE_JOB}/activate
make dev-build
# Bootstrap
- run:
name: Bootstrap the CMS & LMS
command: |
source releases/${CIRCLE_JOB}/activate
make run
make migrate
make collectstatic
# Check that the production build starts
- run:
name: Check production build
command: |
source releases/${CIRCLE_JOB}/activate
make test-cms
make test-lms
# List openedx-docker jobs that will be integrated and executed in a workflow
jobs:
# Quality jobs
Expand Down
47 changes: 47 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ COLOR_RESET = \033[0m
COLOR_SUCCESS = \033[0;32m
COLOR_WARNING = \033[0;33m

# Shell functions
SHELL=bash
define BASH_FUNC_test-service%%
() {
local service=$${1:-CMS}
local environment=$${2:-production}
local url=$${3:-http://localhost:8000}
local http_version=$${4:-1.1}

echo -n "Testing $${service} ($${environment})... "
if curl -vLk --header "Accept: text/html" "$${url}" 2>&1 \
| grep "< HTTP/$${http_version} 200 OK" > /dev/null ; then
echo -e "$(COLOR_SUCCESS)OK$(COLOR_RESET)"
else
echo -e "$(COLOR_ERROR)NO$(COLOR_RESET)"
echo -e "\n$(COLOR_ERROR)--- Error traceback ---"
curl -vLk --header "Accept: text/html" "$${url}"
echo -e "--- End error traceback ---$(COLOR_RESET)"
fi
}
endef
export BASH_FUNC_test-service%%

default: help

# Target release expected tree
Expand Down Expand Up @@ -219,6 +242,30 @@ superuser: ## create a super user
$(MANAGE_LMS) createsuperuser
.PHONY: superuser

test: \
test-cms \
test-lms \
test-cms-dev \
test-lms-dev
test: ## test services (production & development)
.PHONY: test

test-cms: ## test the CMS (production) service
@test-service CMS production http://localhost:8083 1.1
.PHONY: test-cms

test-cms-dev: ## test the CMS (development) service
@test-service CMS development http://localhost:8082 1.0
.PHONY: test-cms-dev

test-lms: ## test the LMS (production) service
@test-service LMS production http://localhost:8073 1.1
.PHONY: test-lms

test-lms-dev: ## test the LMS (development) service
@test-service LMS development http://localhost:8072 1.0
.PHONY: test-lms-dev

tree: \
$(FLAVORED_EDX_RELEASE_PATH)/data/static/production/.keep \
$(FLAVORED_EDX_RELEASE_PATH)/data/static/development/.keep \
Expand Down

0 comments on commit ac01898

Please sign in to comment.