Skip to content

Commit

Permalink
Refactor integration tests to be able to run them in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks committed Sep 12, 2017
1 parent 7c2abde commit 9292bd7
Show file tree
Hide file tree
Showing 108 changed files with 28 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ _testmain.go
/indexers
/log
/public/img/avatar
/integrations/gitea-integration
/integrations/gitea-integration-mysql
/integrations/gitea-integration-pgsql
/integrations/gitea-integration-sqlite
25 changes: 14 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ all: build
.PHONY: clean
clean:
$(GO) clean -i ./...
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA) integrations*.test
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA) integrations*.test integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-sqlite/

required-gofmt-version:
@$(GO) version | grep -q '\(1.7\|1.8\)' || { echo "We require go version 1.7 or 1.8 to format code" >&2 && exit 1; }
Expand Down Expand Up @@ -160,33 +160,36 @@ test-sqlite: integrations.sqlite.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test

.PHONY: test-mysql
test-mysql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.test
test-mysql: integrations.mysql.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test

.PHONY: test-pgsql
test-pgsql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test
test-pgsql: integrations.pgsql.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test


.PHONY: bench-sqlite
bench-sqlite: integrations.sqlite.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.bench .

.PHONY: bench-mysql
bench-mysql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.test -test.bench .
bench-mysql: integrations.mysql.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.bench .

.PHONY: bench-pgsql
bench-pgsql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test -test.bench .
bench-pgsql: integrations.pgsql.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.bench .


.PHONY: integration-test-coverage
integration-test-coverage: integrations.cover.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out

integrations.test: $(SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations
integrations.mysql.test: $(SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.mysql.test

integrations.pgsql.test: $(SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.pgsql.test

integrations.sqlite.test: $(SOURCES)
$(GO) test -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite'
Expand Down
4 changes: 2 additions & 2 deletions integrations/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func initIntegrationTest() {

func prepareTestEnv(t testing.TB) {
assert.NoError(t, models.LoadFixtures())
assert.NoError(t, os.RemoveAll("integrations/gitea-integration"))
assert.NoError(t, com.CopyDir("integrations/gitea-integration-meta", "integrations/gitea-integration"))
assert.NoError(t, os.RemoveAll(setting.RepoRootPath))
assert.NoError(t, com.CopyDir("integrations/gitea-repositories-meta", setting.RepoRootPath))
}

type TestSession struct {
Expand Down
6 changes: 3 additions & 3 deletions integrations/mysql.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ SSL_MODE = disable
PATH = data/gitea.db

[repository]
ROOT = integrations/gitea-integration/gitea-repositories
ROOT = integrations/gitea-integration-mysql/gitea-repositories

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3000
ROOT_URL = http://localhost:3000/
HTTP_PORT = 3001
ROOT_URL = http://localhost:3001/
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = false
Expand Down
6 changes: 3 additions & 3 deletions integrations/pgsql.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ SSL_MODE = disable
PATH = data/gitea.db

[repository]
ROOT = integrations/gitea-integration/gitea-repositories
ROOT = integrations/gitea-integration-pgsql/gitea-repositories

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3000
ROOT_URL = http://localhost:3000/
HTTP_PORT = 3002
ROOT_URL = http://localhost:3002/
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = false
Expand Down
6 changes: 3 additions & 3 deletions integrations/sqlite.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ DB_TYPE = sqlite3
PATH = :memory:

[repository]
ROOT = integrations/gitea-integration/gitea-repositories
ROOT = integrations/gitea-integration-sqlite/gitea-repositories

[server]
SSH_DOMAIN = localhost
HTTP_PORT = 3000
ROOT_URL = http://localhost:3000/
HTTP_PORT = 3003
ROOT_URL = http://localhost:3003/
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = false
Expand Down

0 comments on commit 9292bd7

Please sign in to comment.