Commit 2a01cce5 authored by Alessio Caiazza's avatar Alessio Caiazza

Merge branch 'qmnguyen0711/upgrade-gitaly-image-for-workhorse-integration-test' into 'master'

Use matching gitaly binary for workhorse integration tests

See merge request gitlab-org/gitlab!72271
parents 513b0788 d16d9c57
...@@ -9,24 +9,21 @@ workhorse:verify: ...@@ -9,24 +9,21 @@ workhorse:verify:
.workhorse:test: .workhorse:test:
extends: .workhorse:rules:workhorse extends: .workhorse:rules:workhorse
services:
- name: registry.gitlab.com/gitlab-org/build/cng/gitaly:latest
# Disable the hooks so we don't have to stub the GitLab API
command: ["/usr/bin/env", "GITALY_TESTING_NO_GIT_HOOKS=1", "/scripts/process-wrapper"]
alias: gitaly
variables: variables:
GITALY_ADDRESS: "tcp://gitaly:8075" GITALY_ADDRESS: "tcp://127.0.0.1:8075"
stage: test stage: test
needs: [] needs:
- setup-test-env
script: script:
- go version - go version
- apt-get update && apt-get -y install libimage-exiftool-perl - apt-get update && apt-get -y install libimage-exiftool-perl
- scripts/gitaly-test-build
- make -C workhorse test - make -C workhorse test
workhorse:test using go 1.16: workhorse:test using go 1.16:
extends: .workhorse:test extends: .workhorse:test
image: ${GITLAB_DEPENDENCY_PROXY}golang:1.16 image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7-golang-1.16-git-2.31
workhorse:test using go 1.17: workhorse:test using go 1.17:
extends: .workhorse:test extends: .workhorse:test
image: ${GITLAB_DEPENDENCY_PROXY}golang:1.17 image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.7-golang-1.17-git-2.31
...@@ -13,6 +13,8 @@ else ...@@ -13,6 +13,8 @@ else
BUILD_TIME := $(shell date -u "$(DATE_FMT)") BUILD_TIME := $(shell date -u "$(DATE_FMT)")
endif endif
GOBUILD := go build -ldflags "-X main.Version=$(VERSION_STRING) -X main.BuildTime=$(BUILD_TIME)" GOBUILD := go build -ldflags "-X main.Version=$(VERSION_STRING) -X main.BuildTime=$(BUILD_TIME)"
GITALY := tmp/tests/gitaly/_build/bin/gitaly
GITALY_PID_FILE := gitaly.pid
EXE_ALL := gitlab-resize-image gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse EXE_ALL := gitlab-resize-image gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
INSTALL := install INSTALL := install
BUILD_TAGS := tracer_static tracer_static_jaeger continuous_profiler_stackdriver BUILD_TAGS := tracer_static tracer_static_jaeger continuous_profiler_stackdriver
...@@ -63,7 +65,16 @@ install: $(EXE_ALL) ...@@ -63,7 +65,16 @@ install: $(EXE_ALL)
.PHONY: test .PHONY: test
test: prepare-tests test: prepare-tests
$(call message,$@) $(call message,$@)
@go test -tags "$(BUILD_TAGS)" ./... go test -tags "$(BUILD_TAGS)" ./... ;\
status="$$?" ;\
if [ -f "$(GITALY_PID_FILE)" ] ; then \
echo "Clean up Gitaly server for workhorse integration test" ;\
kill -9 $$(cat $(GITALY_PID_FILE)) ;\
rm $(GITALY_PID_FILE) ;\
else \
echo "Gitaly integration test not running" ;\
fi ;\
exit "$$status"
@echo SUCCESS @echo SUCCESS
.PHONY: clean .PHONY: clean
...@@ -82,9 +93,27 @@ clean-build: ...@@ -82,9 +93,27 @@ 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
run-gitaly: gitaly.pid
$(GITALY_PID_FILE): gitaly.toml
@{ \
if [ -z "$${GITALY_ADDRESS+x}" ] ; then \
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
sed -e 's/^socket_path.*$$/listen_addr = "0.0.0.0:8075"/;s/^\[auth\]$$//;s/^token.*$$//;s/^internal_socket_dir.*$$//' \
$< > $@
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 $@
......
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
...@@ -53,6 +54,10 @@ func realGitalyOkBody(t *testing.T) *api.Response { ...@@ -53,6 +54,10 @@ func realGitalyOkBody(t *testing.T) *api.Response {
return realGitalyAuthResponse(gitOkBody(t)) return realGitalyAuthResponse(gitOkBody(t))
} }
func realGitalyOkBodyWithSidechannel(t *testing.T) *api.Response {
return realGitalyAuthResponse(gitOkBodyWithSidechannel(t))
}
func ensureGitalyRepository(t *testing.T, apiResponse *api.Response) error { func ensureGitalyRepository(t *testing.T, apiResponse *api.Response) error {
ctx, namespace, err := gitaly.NewNamespaceClient(context.Background(), apiResponse.GitalyServer) ctx, namespace, err := gitaly.NewNamespaceClient(context.Background(), apiResponse.GitalyServer)
if err != nil { if err != nil {
...@@ -83,10 +88,18 @@ func ensureGitalyRepository(t *testing.T, apiResponse *api.Response) error { ...@@ -83,10 +88,18 @@ func ensureGitalyRepository(t *testing.T, apiResponse *api.Response) error {
} }
func TestAllowedClone(t *testing.T) { func TestAllowedClone(t *testing.T) {
testAllowedClone(t, realGitalyOkBody(t))
}
func TestAllowedCloneWithSidechannel(t *testing.T) {
gitaly.InitializeSidechannelRegistry(logrus.StandardLogger())
testAllowedClone(t, realGitalyOkBodyWithSidechannel(t))
}
func testAllowedClone(t *testing.T, apiResponse *api.Response) {
skipUnlessRealGitaly(t) skipUnlessRealGitaly(t)
// Create the repository in the Gitaly server // Create the repository in the Gitaly server
apiResponse := realGitalyOkBody(t)
require.NoError(t, ensureGitalyRepository(t, apiResponse)) require.NoError(t, ensureGitalyRepository(t, apiResponse))
// Prepare test server and backend // Prepare test server and backend
...@@ -107,10 +120,18 @@ func TestAllowedClone(t *testing.T) { ...@@ -107,10 +120,18 @@ func TestAllowedClone(t *testing.T) {
} }
func TestAllowedShallowClone(t *testing.T) { func TestAllowedShallowClone(t *testing.T) {
testAllowedShallowClone(t, realGitalyOkBody(t))
}
func TestAllowedShallowCloneWithSidechannel(t *testing.T) {
gitaly.InitializeSidechannelRegistry(logrus.StandardLogger())
testAllowedShallowClone(t, realGitalyOkBodyWithSidechannel(t))
}
func testAllowedShallowClone(t *testing.T, apiResponse *api.Response) {
skipUnlessRealGitaly(t) skipUnlessRealGitaly(t)
// Create the repository in the Gitaly server // Create the repository in the Gitaly server
apiResponse := realGitalyOkBody(t)
require.NoError(t, ensureGitalyRepository(t, apiResponse)) require.NoError(t, ensureGitalyRepository(t, apiResponse))
// Prepare test server and backend // Prepare test server and backend
......
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