Commit 832848cf authored by Alessio Caiazza's avatar Alessio Caiazza

Fix workhorse make test

Make test should be able to run also on a clean clone of the
repository.

Do not generate the gitaly configuration if gitaly integration tests
are not needed.

If gitaly integration tests are requested, then make should be able to
generate all the necessary binaries and configuration files without
user interaction.

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/349194
parent 507613fd
...@@ -9,3 +9,4 @@ testdata/alt-public ...@@ -9,3 +9,4 @@ testdata/alt-public
/_build /_build
coverage.html coverage.html
/*.toml /*.toml
/gitaly.pid
...@@ -65,7 +65,12 @@ install: $(EXE_ALL) ...@@ -65,7 +65,12 @@ install: $(EXE_ALL)
.PHONY: test .PHONY: test
test: prepare-tests test: prepare-tests
$(call message,$@) $(call message,$@)
go test -tags "$(BUILD_TAGS)" ./... ;\ @if [ -z "$${GITALY_ADDRESS+x}" ] ; then \
echo "To run gitaly integration tests set GITALY_ADDRESS=tcp://127.0.0.1:8075" ; \
else \
$(MAKE) run-gitaly ; \
fi
@go test -tags "$(BUILD_TAGS)" ./... ;\
status="$$?" ;\ status="$$?" ;\
if [ -f "$(GITALY_PID_FILE)" ] ; then \ if [ -f "$(GITALY_PID_FILE)" ] ; then \
echo "Clean up Gitaly server for workhorse integration test" ;\ echo "Clean up Gitaly server for workhorse integration test" ;\
...@@ -93,27 +98,24 @@ clean-build: ...@@ -93,27 +98,24 @@ clean-build:
rm -rf $(TARGET_DIR) rm -rf $(TARGET_DIR)
.PHONY: prepare-tests .PHONY: prepare-tests
prepare-tests: run-gitaly
prepare-tests: testdata/data/group/test.git $(EXE_ALL) prepare-tests: testdata/data/group/test.git $(EXE_ALL)
prepare-tests: testdata/scratch prepare-tests: testdata/scratch
.PHONY: run-gitaly .PHONY: run-gitaly
run-gitaly: gitaly.pid run-gitaly: $(GITALY_PID_FILE)
$(GITALY_PID_FILE): gitaly.toml $(GITALY_PID_FILE): gitaly.toml
@{ \ $(call message, "Starting gitaly")
if [ -z "$${GITALY_ADDRESS+x}" ] ; then \ cd ..; GITALY_TESTING_NO_GIT_HOOKS=1 GITALY_PID_FILE=workhorse/$(GITALY_PID_FILE) $(GITALY) workhorse/gitaly.toml &
echo "To run gitaly integration tests set GITALY_ADDRESS=tcp://127.0.0.1:8075" ; \
else \
cd .. ; \
GITALY_TESTING_NO_GIT_HOOKS=1 GITALY_PID_FILE=workhorse/$(GITALY_PID_FILE) $(GITALY) workhorse/gitaly.toml ; \
fi \
} &
gitaly.toml: ../tmp/tests/gitaly/config.toml gitaly.toml: ../tmp/tests/gitaly/config.toml
sed -e 's/^socket_path.*$$/listen_addr = "0.0.0.0:8075"/;s/^\[auth\]$$//;s/^token.*$$//;s/^internal_socket_dir.*$$//' \ sed -e 's/^socket_path.*$$/listen_addr = "0.0.0.0:8075"/;s/^\[auth\]$$//;s/^token.*$$//;s/^internal_socket_dir.*$$//' \
$< > $@ $< > $@
../tmp/tests/gitaly/config.toml:
$(call message, "Building a complete test environment")
cd .. ; ./scripts/setup-test-env
testdata/data/group/test.git: testdata/data/group/test.git:
$(call message,$@) $(call message,$@)
git clone --quiet --bare https://gitlab.com/gitlab-org/gitlab-test.git $@ git clone --quiet --bare https://gitlab.com/gitlab-org/gitlab-test.git $@
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment