From ca5a773c34e4c7edbfbc973b9a8770de5c47f548 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Mon, 6 Nov 2017 16:44:54 -0600 Subject: [PATCH] Initial jenkinsfile --- Dockerfile_jenkins_ubuntu32 | 18 ++++++++++ Jenkinsfile | 55 ++++++++++++++++++++++++++++++ services/retention/service_test.go | 28 ++++++++++----- 3 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 Dockerfile_jenkins_ubuntu32 create mode 100644 Jenkinsfile diff --git a/Dockerfile_jenkins_ubuntu32 b/Dockerfile_jenkins_ubuntu32 new file mode 100644 index 0000000000..796971b89c --- /dev/null +++ b/Dockerfile_jenkins_ubuntu32 @@ -0,0 +1,18 @@ +FROM ioft/i386-ubuntu:xenial + +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + wget \ + mercurial \ + git && \ + rm -rf /var/lib/apt/lists/* + +# Install go +ENV GOPATH /go +ENV GO_VERSION 1.9.2 +ENV GO_ARCH 386 +RUN wget -q https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && \ + tar -C /usr/local/ -xf /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz && \ + mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" && \ + rm /go${GO_VERSION}.linux-${GO_ARCH}.tar.gz +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..16361c12b4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,55 @@ +readTrusted 'Dockerfile_jenkins_ubuntu32' + +pipeline { + agent none + + stages { + stage('64bit') { + agent { + docker { + image 'golang:1.9.2' + } + } + + steps { + sh """ + mkdir -p /go/src/github.com/influxdata + cp -a $WORKSPACE /go/src/github.com/influxdata/influxdb + + cd /go/src/github.com/influxdata/influxdb + go get github.com/sparrc/gdm + gdm restore + """ + + sh """ + cd /go/src/github.com/influxdata/influxdb + go test -parallel=1 ./... + """ + } + } + + stage('32bit') { + agent { + dockerfile { + filename 'Dockerfile_jenkins_ubuntu32' + } + } + + steps { + sh """ + mkdir -p /go/src/github.com/influxdata + cp -a $WORKSPACE /go/src/github.com/influxdata/influxdb + + cd /go/src/github.com/influxdata/influxdb + go get github.com/sparrc/gdm + gdm restore + """ + + sh """ + cd /go/src/github.com/influxdata/influxdb + go test -parallel=1 ./... + """ + } + } + } +} diff --git a/services/retention/service_test.go b/services/retention/service_test.go index c6cc45df02..2f066e6de5 100644 --- a/services/retention/service_test.go +++ b/services/retention/service_test.go @@ -60,7 +60,7 @@ func TestService_OpenClose(t *testing.T) { // This reproduces https://github.com/influxdata/influxdb/issues/8819 func TestService_8819_repro(t *testing.T) { for i := 0; i < 1000; i++ { - s, errC := testService_8819_repro(t) + s, errC, done := testService_8819_repro(t) if err := s.Open(); err != nil { t.Fatal(err) @@ -70,6 +70,8 @@ func TestService_8819_repro(t *testing.T) { if err := <-errC; err != nil { t.Fatalf("%dth iteration: %v", i, err) } + // Mark that we do not expect more errors in case it runs one more time. + close(done) if err := s.Close(); err != nil { t.Fatal(err) @@ -77,11 +79,12 @@ func TestService_8819_repro(t *testing.T) { } } -func testService_8819_repro(t *testing.T) (*Service, chan error) { +func testService_8819_repro(t *testing.T) (*Service, chan error, chan struct{}) { c := retention.NewConfig() c.CheckInterval = toml.Duration(time.Millisecond) s := NewService(c) errC := make(chan error, 1) // Buffer Important to prevent deadlock. + done := make(chan struct{}) // A database and a bunch of shards var mu sync.Mutex @@ -110,6 +113,13 @@ func testService_8819_repro(t *testing.T) (*Service, chan error) { }, } + sendError := func(err error) { + select { + case errC <- err: + case <-done: + } + } + s.MetaClient.DatabasesFn = func() []meta.DatabaseInfo { mu.Lock() defer mu.Unlock() @@ -118,13 +128,13 @@ func testService_8819_repro(t *testing.T) (*Service, chan error) { s.MetaClient.DeleteShardGroupFn = func(database string, policy string, id uint64) error { if database != "db0" { - errC <- fmt.Errorf("wrong db name: %s", database) + sendError(fmt.Errorf("wrong db name: %s", database)) return nil } else if policy != "autogen" { - errC <- fmt.Errorf("wrong rp name: %s", policy) + sendError(fmt.Errorf("wrong rp name: %s", policy)) return nil } else if id != 1 { - errC <- fmt.Errorf("wrong shard group id: %d", id) + sendError(fmt.Errorf("wrong shard group id: %d", id)) return nil } @@ -162,17 +172,17 @@ func testService_8819_repro(t *testing.T) (*Service, chan error) { } if !found { - errC <- fmt.Errorf("local shard %d present, yet it's missing from meta store. %v -- %v ", lid, shards, localShards) + sendError(fmt.Errorf("local shard %d present, yet it's missing from meta store. %v -- %v ", lid, shards, localShards)) return nil } } // We should have removed shards 3 and 9 if !reflect.DeepEqual(localShards, []uint64{5, 8, 11}) { - errC <- fmt.Errorf("removed shards still present locally: %v", localShards) + sendError(fmt.Errorf("removed shards still present locally: %v", localShards)) return nil } - errC <- nil + sendError(nil) return nil } @@ -202,7 +212,7 @@ func testService_8819_repro(t *testing.T) (*Service, chan error) { return nil } - return s, errC + return s, errC, done } type Service struct {