Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test fixes #459

Merged
merged 4 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ CI_VERSION ?= v1

TEST_PRUNE_WITH_IMAGE ?= false

GO_TAGS = forceposix

MAKEFILE := $(CI_PATH)/Makefile.main
$(MAKEFILE):
git clone --quiet --branch $(CI_VERSION) --depth 1 $(CI_REPOSITORY) $(CI_PATH);

-include $(MAKEFILE)

GOTEST_BASE = $(GOTEST) -timeout 20m -parallel 1 -count 1 -ldflags "$(LD_FLAGS)"
GOTEST_INTEGRATION = $(GOTEST_BASE) -tags=integration
GOTEST_REGRESSION = $(GOTEST_BASE) -tags=regression
GOTEST_BASE = go test -v -timeout 20m -parallel 1 -count 1 -ldflags "$(LD_FLAGS)"
GOTEST_INTEGRATION = $(GOTEST_BASE) -tags="forceposix integration"
GOTEST_REGRESSION = $(GOTEST_BASE) -tags="forceposix regression"

OS := $(shell uname)

Expand Down
12 changes: 3 additions & 9 deletions cmd/srcd-server/engine/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package engine
import (
"context"
"fmt"
"time"

"github.com/docker/docker/api/types/container"
"github.com/src-d/engine/components"
Expand All @@ -24,21 +23,16 @@ func createBblfshWeb(opts ...docker.ConfigOption) docker.StartFunc {
return err
}

log.Infof("starting bblfshd web")
log.Infof("starting bblfsh web")

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), startComponentTimeout)
defer cancel()

config := &container.Config{
Image: bblfshWeb.ImageWithVersion(),
Cmd: []string{fmt.Sprintf("-bblfsh-addr=%s:%d", bblfshd.Name, components.BblfshParsePort)},
}
host := &container.HostConfig{
// TODO(erizocosmico): Bblfsh web tries to connect to bblfsh before
// we have a change to join to the network, so we have to link the two
// containers.
Links: []string{bblfshd.Name},
}
host := &container.HostConfig{}
docker.ApplyOptions(config, host, opts...)

return docker.Start(ctx, config, host, bblfshWeb.Name)
Expand Down
27 changes: 8 additions & 19 deletions cmdtests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -73,7 +72,7 @@ func (s *InitTestSuite) TestWithoutWorkdir() {

workdir, _ := os.Getwd()
expectedMsg := [2]string{
logMsg("starting daemon with working directory: %s", workdir),
fmt.Sprintf("starting daemon with working directory: %s", workdir),
"daemon started",
}

Expand All @@ -91,7 +90,7 @@ func (s *InitTestSuite) TestWithValidWorkdir() {
actualMsg := s.getLogMessages(r.Combined())

expectedMsg := [2]string{
logMsg("starting daemon with working directory: %s", s.validWorkDir),
fmt.Sprintf("starting daemon with working directory: %s", s.validWorkDir),
"daemon started",
}

Expand Down Expand Up @@ -124,8 +123,8 @@ func (s *InitTestSuite) TestWithRunningDaemon() {
actualMsg := s.getLogMessages(r.Combined())

expectedMsg := [3]string{
logMsg("removing container %s", components.Daemon.Name),
logMsg("starting daemon with working directory: %s", s.validWorkDir),
fmt.Sprintf("removing container %s", components.Daemon.Name),
fmt.Sprintf("starting daemon with working directory: %s", s.validWorkDir),
"daemon started",
}

Expand All @@ -149,10 +148,10 @@ func (s *InitTestSuite) TestWithRunningOtherComponents() {
actualMsg := s.getLogMessages(r.Combined())

expectedMsg := [5]string{
logMsg("removing container %s", components.Bblfshd.Name),
logMsg("removing container %s", components.Daemon.Name),
logMsg("removing container %s", components.Gitbase.Name),
logMsg("starting daemon with working directory: %s", s.validWorkDir),
fmt.Sprintf("removing container %s", components.Bblfshd.Name),
fmt.Sprintf("removing container %s", components.Daemon.Name),
fmt.Sprintf("removing container %s", components.Gitbase.Name),
fmt.Sprintf("starting daemon with working directory: %s", s.validWorkDir),
"daemon started",
}

Expand Down Expand Up @@ -261,13 +260,3 @@ func (s *InitTestSuite) TestRefreshWorkdir() {
`)
require.Contains(r.Stdout(), expected)
}

// formats string the same way as it is printed by logger
func logMsg(format string, args ...string) string {
escapedArgs := make([]interface{}, len(args))
for i, v := range args {
escapedArgs[i] = strings.Replace(v, `\`, `\\`, -1)
}

return fmt.Sprintf(format, escapedArgs...)
}
4 changes: 2 additions & 2 deletions run-integration-tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ cd ../..
:: compile engine-cli
if not exist build mkdir build
if not exist build/engine_windows_amd64 mkdir build/engine_windows_amd64
go build -o build/engine_windows_amd64/srcd.exe ./cmd/srcd
go build -tags=forceposix -o build/engine_windows_amd64/srcd.exe ./cmd/srcd

:: run tests
set SRCD_BIN=../build/engine_windows_amd64/srcd.exe
go test -parallel 1 -count 1 -tags=integration github.com/src-d/engine/cmdtests/ -v
go test -timeout 20m -parallel 1 -count 1 -tags="forceposix integration" github.com/src-d/engine/cmdtests/ -v