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 9, 2019
1 parent d960e46 commit ccec536
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 8 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
63 changes: 55 additions & 8 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 @@ -174,14 +197,14 @@ fetch-release: ## fetch openedx release sources
.PHONY: fetch-release

info: ## get activated release info
@echo "\n.:: OPENEDX-DOCKER ::.\n"
@echo "== Active configuration ==\n"
@echo "* EDX_RELEASE : $(COLOR_INFO)$(EDX_RELEASE)$(COLOR_RESET)"
@echo "* FLAVOR : $(COLOR_INFO)$(FLAVOR)$(COLOR_RESET)"
@echo "* FLAVORED_EDX_RELEASE_PATH : $(COLOR_INFO)$(FLAVORED_EDX_RELEASE_PATH)$(COLOR_RESET)"
@echo "* EDX_RELEASE_REF : $(COLOR_INFO)$(EDX_RELEASE_REF)$(COLOR_RESET)"
@echo "* EDX_DEMO_RELEASE_REF : $(COLOR_INFO)$(EDX_DEMO_RELEASE_REF)$(COLOR_RESET)"
@echo ""
@echo -e "\n.:: OPENEDX-DOCKER ::.\n"
@echo -e "== Active configuration ==\n"
@echo -e "* EDX_RELEASE : $(COLOR_INFO)$(EDX_RELEASE)$(COLOR_RESET)"
@echo -e "* FLAVOR : $(COLOR_INFO)$(FLAVOR)$(COLOR_RESET)"
@echo -e "* FLAVORED_EDX_RELEASE_PATH : $(COLOR_INFO)$(FLAVORED_EDX_RELEASE_PATH)$(COLOR_RESET)"
@echo -e "* EDX_RELEASE_REF : $(COLOR_INFO)$(EDX_RELEASE_REF)$(COLOR_RESET)"
@echo -e "* EDX_DEMO_RELEASE_REF : $(COLOR_INFO)$(EDX_DEMO_RELEASE_REF)$(COLOR_RESET)"
@echo -e ""
.PHONY: info

logs: ## get development logs
Expand Down Expand Up @@ -211,6 +234,30 @@ superuser: run ## 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 ccec536

Please sign in to comment.