implement acceptance tests in docker for dev machine

This commit is contained in:
Willy Kloucek
2020-11-25 14:29:02 +01:00
committed by Phil Davis
parent f9f90568b4
commit 1c409c64a1
13 changed files with 567 additions and 37 deletions

View File

@@ -0,0 +1,232 @@
SHELL := bash
# define standard colors
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
PURPLE := $(shell tput -Txterm setaf 5)
BLUE := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
## default values only for sub-make calls
COMPOSE_FILE ?= src/redis.yml:src/ocis-base.yml:src/acceptance.yml
## user input
BEHAT_FEATURE ?=
CORE_BRANCH ?= master
CORE_COMMIT ?= 52105a981c0c74fc81c84218e9076d443b06f074
ifdef OCIS_IMAGE_TAG
COMPOSE_FILE := $(COMPOSE_FILE):src/ocis-image.yml
else
COMPOSE_FILE := $(COMPOSE_FILE):src/ocis-build.yml
endif
OCIS_IMAGE_TAG ?= latest
# static
DIVIDE_INTO_NUM_PARTS := 10
PARTS = 1 2 3 4 5 6 7 8 9 10
COMPOSE_PROJECT_NAME := ocis-acceptance-tests
## make definition
.PHONY: help
help:
@echo "Please use 'make <target>' where <target> is one of the following:"
@echo
@echo -e "${PURPLE}docs: https://owncloud.github.io/ocis/development/testing/#testing-with-test-suite-in-docker${RESET}\n"
@echo
@echo -e "oCIS feature tests and test suites can be found here:"
@echo -e "\thttps://github.com/owncloud/ocis/tree/master/tests/acceptance/features"
@echo
@echo -e "ownCloud feature tests and test suites can be found here:"
@echo -e "\thttps://github.com/owncloud/core/tree/master/tests/acceptance/features"
@echo
@echo -e "The oCIS to be tested will be build from your current working state."
@echo -e "You also can select the oCIS Docker image for all tests by setting"
@echo -e "\tmake ... ${YELLOW}OCIS_IMAGE_TAG=latest${RESET}"
@echo -e "where ${YELLOW}latest${RESET} is an example for any valid Docker image tag from"
@echo -e "https://hub.docker.com/r/owncloud/ocis."
@echo
@echo -e "${GREEN}Run full oCIS test suites against oCIS with oCIS storage:${RESET}\n"
@echo -e "\tmake localApiTests-apiBasic-ocis\t\t${BLUE}run apiBasic test suite${RESET}"
@echo -e "\tmake localApiTests-apiOcisSpecific-ocis\t\t${BLUE}run apiOcisSPecific test suite${RESET}"
@echo
@echo -e "${GREEN}Run full oCIS test suites against oCIS with ownCloud storage:${RESET}\n"
@echo -e "\tmake localApiTests-apiBasic-owncloud\t\t${BLUE}run apiBasic test suite${RESET}"
@echo -e "\tmake localApiTests-apiOcisSpecific-owncloud\t${BLUE}run apiOcisSpecific test suite${RESET}"
@echo
@echo -e "${GREEN}Run full ownCloud test suites against oCIS with oCIS storage:${RESET}\n"
@echo -e "\tmake Core-API-Tests-ocis-storage-${RED}X${RESET}\t\t${BLUE}run test suite number X, where ${RED}X = 1 .. 10${RESET}"
@echo
@echo -e "${GREEN}Run full ownCloud test suites against oCIS with ownCloud storage:${RESET}\n"
@echo -e "\tmake Core-API-Tests-owncloud-storage-${RED}X${RESET}\t\t${BLUE}run test suite number X, where ${RED}X = 1 .. 10${RESET}"
@echo
@echo -e "${GREEN}Run an oCIS feature test against oCIS with oCIS storage:${RESET}\n"
@echo -e "\tmake test-ocis-feature-ocis-storage ${YELLOW}BEHAT_FEATURE='...'${RESET}\t${BLUE}run single feature test${RESET}"
@echo
@echo -e "\twhere ${YELLOW}BEHAT_FEATURE='...'${RESET} contains a relative path to the feature definition."
@echo -e "\texample: ${RED}tests/acceptance/features/apiOcisSpecific/apiAuthOcs-ocsDELETEAuth.feature${RESET}"
@echo
@echo -e "${GREEN}Run an oCIS feature test against oCIS with owncloud storage:${RESET}\n"
@echo -e "\tmake test-ocis-feature-owncloud-storage ${YELLOW}BEHAT_FEATURE='...'${RESET}\t${BLUE}run single feature test${RESET}"
@echo
@echo -e "\twhere ${YELLOW}BEHAT_FEATURE='...'${RESET} contains a relative path to the feature definition."
@echo -e "\texample: ${RED}tests/acceptance/features/apiOcisSpecific/apiAuthOcs-ocsDELETEAuth.feature${RESET}"
@echo
@echo -e "${GREEN}Run an ownCloud feature test against oCIS with oCIS storage:${RESET}\n"
@echo -e "\tmake test-oc10-feature-ocis-storage ${YELLOW}BEHAT_FEATURE='...'${RESET}\t${BLUE}run single feature test${RESET}"
@echo
@echo -e "\twhere ${YELLOW}BEHAT_FEATURE='...'${RESET} contains a relative path to the feature definition."
@echo -e "\texample: ${RED}tests/acceptance/features/apiAuth/cors.feature${RESET}"
@echo
@echo -e "${GREEN}Run an ownCloud feature test against oCIS with owncloud storage:${RESET}\n"
@echo -e "\tmake test-oc10-feature-owncloud-storage ${YELLOW}BEHAT_FEATURE='...'${RESET}\t${BLUE}run single feature test${RESET}"
@echo
@echo -e "\twhere ${YELLOW}BEHAT_FEATURE='...'${RESET} contains a relative path to the feature definition."
@echo -e "\texample: ${RED}tests/acceptance/features/apiAuth/cors.feature${RESET}"
@echo
@echo
@echo -e "${GREEN}Show output of tests:${RESET}\n"
@echo -e "\tmake show-test-logs\t\t${BLUE}show output of running or finished tests${RESET}"
@echo
@echo
@echo -e "${GREEN}Clean up after testing:${RESET}\n"
@echo -e "\tmake clean\t${BLUE}clean up all${RESET}"
@echo -e "\tmake clean-docker-container\t\t${BLUE}stops and removes used docker containers${RESET}"
@echo -e "\tmake clean-docker-volumes\t\t${BLUE}removes used docker volumes (used for caching)${RESET}"
@echo
.PHONY: test-ocis-feature-ocis-storage
test-ocis-feature-ocis-storage: ## test a ocis feature with oCIS storage, useage: make ... BEHAT_FEATURE='tests/acceptance/features/apiOcisSpecific/apiAuthOcs-ocsDELETEAuth.feature:7'
@TEST_SOURCE=ocis \
STORAGE=ocis \
BEHAT_FEATURE=$(BEHAT_FEATURE) \
$(MAKE) --no-print-directory testSuite
.PHONY: test-ocis-feature-owncloud-storage
test-ocis-feature-owncloud-storage: ## test a ocis feature with oc10 storage, useage: make ... BEHAT_FEATURE='tests/acceptance/features/apiOcisSpecific/apiAuthOcs-ocsDELETEAuth.feature:7'
@TEST_SOURCE=ocis \
STORAGE=owncloud \
BEHAT_FEATURE=$(BEHAT_FEATURE) \
$(MAKE) --no-print-directory testSuite
.PHONY: test-oc10-feature-ocis-storage
test-oc10-feature-ocis-storage: ## test a oC10 feature with oCIS storage, useage: make ... BEHAT_FEATURE='tests/acceptance/features/apiAuth/cors.feature'
@TEST_SOURCE=oc10 \
STORAGE=ocis \
BEHAT_FEATURE=$(BEHAT_FEATURE) \
$(MAKE) --no-print-directory testSuite
.PHONY: test-oc10-feature-owncloud-storage
test-oc10-feature-owncloud-storage: ## test a oC10 feature with oc10 storage, useage: make ... BEHAT_FEATURE='tests/acceptance/features/apiAuth/cors.feature'
@TEST_SOURCE=oc10 \
STORAGE=owncloud \
BEHAT_FEATURE=$(BEHAT_FEATURE) \
$(MAKE) --no-print-directory testSuite
.PHONY: localApiTests-apiOcisSpecific-owncloud
localApiTests-apiOcisSpecific-owncloud: ## run apiOcisSpecific test suite with owncloud storage
@TEST_SOURCE=oc10 \
STORAGE=owncloud \
BEHAT_SUITE=apiOcisSpecific \
$(MAKE) --no-print-directory testSuite
.PHONY: localApiTests-apiBasic-owncloud
localApiTests-apiBasic-owncloud: ## run apiBasic test suite with owncloud storage
@TEST_SOURCE=ocis \
STORAGE=owncloud \
BEHAT_SUITE=apiBasic \
$(MAKE) --no-print-directory testSuite
.PHONY: localApiTests-apiOcisSpecific-ocis
localApiTests-apiOcisSpecific-ocis: ## run apiOcisSPecific test suite with ocis storage
@TEST_SOURCE=ocis \
STORAGE=ocis \
BEHAT_SUITE=apiOcisSpecific \
$(MAKE) --no-print-directory testSuite
.PHONY: localApiTests-apiBasic-ocis
localApiTests-apiBasic-ocis: ## run apiBasic test suite with ocis storage
@TEST_SOURCE=ocis \
STORAGE=ocis \
BEHAT_SUITE=apiBasic \
$(MAKE) --no-print-directory testSuite
targets = $(addprefix Core-API-Tests-owncloud-storage-,$(PARTS))
.PHONY: $(targets)
$(targets):
@$(eval RUN_PART=$(shell echo "$@" | tr -dc '0-9'))
@TEST_SOURCE=oc10 \
STORAGE=owncloud \
RUN_PART=$(RUN_PART) \
$(MAKE) --no-print-directory testSuite
targets = $(addprefix Core-API-Tests-ocis-storage-,$(PARTS))
.PHONY: $(targets)
$(targets):
@$(eval RUN_PART=$(shell echo "$@" | tr -dc '0-9'))
@TEST_SOURCE=oc10 \
STORAGE=ocis \
RUN_PART=$(RUN_PART) \
$(MAKE) --no-print-directory testSuite
.PHONY: testSuite
testSuite: clean-docker-container
@COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
COMPOSE_FILE=$(COMPOSE_FILE) \
STORAGE=$(STORAGE) \
TEST_SOURCE=$(TEST_SOURCE) \
OCIS_IMAGE_TAG=$(OCIS_IMAGE_TAG) \
BEHAT_SUITE=$(BEHAT_SUITE) \
BEHAT_FEATURE=$(BEHAT_FEATURE) \
CORE_BRANCH=$(CORE_BRANCH) \
CORE_COMMIT=$(CORE_COMMIT) \
DIVIDE_INTO_NUM_PARTS=$(DIVIDE_INTO_NUM_PARTS) \
RUN_PART=$(RUN_PART) \
docker-compose up -d --build --remove-orphans --force-recreate
.PHONY: show-test-logs
show-test-logs: ## show logs of test
@COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
COMPOSE_FILE=$(COMPOSE_FILE) \
docker logs -f ocis-acceptance-tests_acceptance-tests_1 | less
.PHONY: clean-docker-container
clean-docker-container: ## clean docker containers created during acceptance tests
@COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
COMPOSE_FILE=$(COMPOSE_FILE) \
BEHAT_SUITE="" \
CORE_BRANCH="" \
CORE_COMMIT="" \
DIVIDE_INTO_NUM_PARTS="" \
OCIS_IMAGE_TAG="" \
RUN_PART="" \
STORAGE="" \
TEST_SOURCE="" \
docker-compose down --remove-orphans
.PHONY: clean-docker-volumes
clean-docker-volumes: ## clean docker volumes created during acceptance tests
@COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
STORAGE=$(STORAGE) \
COMPOSE_FILE=$(COMPOSE_FILE) \
BEHAT_SUITE="" \
CORE_BRANCH="" \
CORE_COMMIT="" \
DIVIDE_INTO_NUM_PARTS="" \
OCIS_IMAGE_TAG="" \
RUN_PART="" \
STORAGE="" \
TEST_SOURCE="" \
docker-compose down --remove-orphans -v
.PHONY: clean-files
@$(MAKE) --no-print-directory -C ../. clean-tests
.PHONY: clean
clean: clean-docker-container clean-docker-volumes clean-files ## clean all

View File

@@ -0,0 +1,27 @@
services:
acceptance-tests:
image: owncloudci/php:7.4
command: /bin/bash /test/run-tests.sh
environment:
OCIS_ROOT: /drone/src
PATH_TO_CORE: /srv/app/testrunner
SKELETON_DIR: /srv/app/tmp/testing/data/apiSkeleton
TEST_OCIS: "true"
TEST_SERVER_URL: https://ocis-server:9200
TESTING_DIR: /srv/app/tmp/testing
CORE_BRANCH: $CORE_BRANCH
CORE_COMMIT: $CORE_COMMIT
STORAGE: $STORAGE
TEST_SOURCE: $TEST_SOURCE
BEHAT_SUITE: ${BEHAT_SUITE:-}
BEHAT_FEATURE: ${BEHAT_FEATURE:-}
DIVIDE_INTO_NUM_PARTS: $DIVIDE_INTO_NUM_PARTS
RUN_PART: $RUN_PART
volumes:
- ./run-tests.sh:/test/run-tests.sh
- oCISownCloud10testsuite:/srv
- ../../../../:/drone/src
volumes:
oCISownCloud10testsuite:

View File

@@ -0,0 +1,30 @@
services:
ocis-server:
environment:
STORAGE_HOME_DRIVER: $STORAGE
STORAGE_USERS_DRIVER: $STORAGE
STORAGE_DRIVER_OCIS_ROOT: /srv/app/tmp/ocis/storage/users
STORAGE_DRIVER_LOCAL_ROOT: /srv/app/tmp/ocis/local/root
STORAGE_METADATA_ROOT: /srv/app/tmp/ocis/metadata
STORAGE_DRIVER_OWNCLOUD_DATADIR: /srv/app/tmp/ocis/owncloud/data
STORAGE_DRIVER_OWNCLOUD_REDIS_ADDR: redis:6379
STORAGE_LDAP_IDP: https://ocis-server:9200
STORAGE_OIDC_ISSUER: https://ocis-server:9200
PROXY_OIDC_ISSUER: https://ocis-server:9200
STORAGE_HOME_DATA_SERVER_URL: http://ocis-server:9155/data
STORAGE_DATAGATEWAY_PUBLIC_URL: https://ocis-server:9200/data
STORAGE_USERS_DATA_SERVER_URL: http://ocis-server:9158/data
STORAGE_FRONTEND_PUBLIC_URL: https://ocis-server:9200
STORAGE_SHARING_USER_JSON_FILE: /srv/app/tmp/ocis/shares.json
PROXY_ENABLE_BASIC_AUTH: "true"
PHOENIX_WEB_CONFIG: /drone/src/ocis/tests/config/drone/ocis-config.json
KONNECTD_IDENTIFIER_REGISTRATION_CONF: /drone/src/ocis/tests/config/drone/identifier-registration.yml
KONNECTD_ISS: https://ocis-server:9200
KONNECTD_TLS: "true"
ACCOUNTS_HASH_DIFFICULTY: 4
volumes:
- ../../../config:/drone/src/ocis/tests/config
- oCISownCloud10testsuite:/srv
volumes:
oCISownCloud10testsuite:

View File

@@ -0,0 +1,5 @@
services:
ocis-server:
build:
context: ./../../../../.
dockerfile: Dockerfile

View File

@@ -0,0 +1,3 @@
services:
ocis-server:
image: owncloud/ocis:$OCIS_IMAGE_TAG

View File

@@ -0,0 +1,5 @@
services:
redis:
image: webhippie/redis
environment:
REDIS_DATABASES: 1

View File

@@ -0,0 +1,103 @@
#!/bin/bash
git config --global advice.detachedHead false
## GET DEPENDENCIES
if cd $TESTING_DIR > /dev/null 2>&1
then
git pull
else
git clone -b master --depth=1 https://github.com/owncloud/testing.git $TESTING_DIR
fi
if cd $PATH_TO_CORE > /dev/null 2>&1
then
git checkout $CORE_BRANCH
git pull
git checkout $CORE_COMMIT
else
git clone -b $CORE_BRANCH --single-branch --no-tags https://github.com/owncloud/core.git $PATH_TO_CORE
cd $PATH_TO_CORE
git checkout $CORE_COMMIT
fi
## CONFIGURE TEST
if [ "$TEST_SOURCE" = "oc10" ]
then
if [ "$STORAGE" = "owncloud" ]
then
export OCIS_REVA_DATA_ROOT='/srv/app/tmp/ocis/owncloud/data/'
export DELETE_USER_DATA_CMD=''
export BEHAT_FILTER_TAGS='~@notToImplementOnOCIS&&~@toImplementOnOCIS&&~comments-app-required&&~@federation-app-required&&~@notifications-app-required&&~systemtags-app-required&&~@local_storage&&~@skipOnOcis-OC-Storage'
export OCIS_SKELETON_STRATEGY='copy'
export EXPECTED_FAILURES_FILE='/drone/src/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt'
elif [ "$STORAGE" = "ocis" ]
then
export OCIS_REVA_DATA_ROOT=''
export DELETE_USER_DATA_CMD='rm -rf /srv/app/tmp/ocis/storage/users/nodes/root/* /srv/app/tmp/ocis/storage/users/nodes/*-*-*-*'
export BEHAT_FILTER_TAGS='~@notToImplementOnOCIS&&~@toImplementOnOCIS&&~comments-app-required&&~@federation-app-required&&~@notifications-app-required&&~systemtags-app-required&&~@local_storage&&~@skipOnOcis-OCIS-Storage'
export OCIS_SKELETON_STRATEGY='upload'
export EXPECTED_FAILURES_FILE='/drone/src/tests/acceptance/expected-failures-on-OCIS-storage.txt'
else
echo "non existing STORAGE selected"
exit 1
fi
unset BEHAT_SUITE
elif [ "$TEST_SOURCE" = "ocis" ]
then
if [ "$STORAGE" = "owncloud" ]
then
export BEHAT_FILTER_TAGS='~@skipOnOcis-OC-Storage'
export DELETE_USER_DATA_CMD=''
export OCIS_REVA_DATA_ROOT='/srv/app/tmp/ocis/owncloud/data/'
export OCIS_SKELETON_STRATEGY='copy'
elif [ "$STORAGE" = "ocis" ]
then
export BEHAT_FILTER_TAGS='~@skipOnOcis-OCIS-Storage'
export DELETE_USER_DATA_CMD='rm -rf /srv/app/tmp/ocis/storage/users/nodes/root/* /srv/app/tmp/ocis/storage/users/nodes/*-*-*-*'
export OCIS_REVA_DATA_ROOT=''
export OCIS_SKELETON_STRATEGY='upload'
else
echo "non existing storage selected"
exit 1
fi
unset DIVIDE_INTO_NUM_PARTS
unset RUN_PART
else
echo "non existing TEST_SOURCE selected"
exit 1
fi
if [ ! -z "$BEHAT_FEATURE" ]
then
echo "feature selected: " + $BEHAT_FEATURE
# allow to run without filters if its a feature
unset BEHAT_FILTER_TAGS
unset DIVIDE_INTO_NUM_PARTS
unset RUN_PART
unset EXPECTED_FAILURES_FILE
fi
## RUN TEST
if [ "$TEST_SOURCE" = "oc10" ]
then
make -C /srv/app/testrunner test-acceptance-api
elif [ "$TEST_SOURCE" = "ocis" ]
then
cd $OCIS_ROOT
sleep 10
make test-acceptance-api
else
echo "non existing TEST_SOURCE selected"
exit 1
fi
chmod -R 777 vendor-bin/**/vendor vendor-bin/**/composer.lock tests/acceptance/output