Skip to content

Commit

Permalink
roachtest: add acceptance/build-info
Browse files Browse the repository at this point in the history
Move the build-info acceptance test to a new acceptance/build-info
roachtest. Move the existing cli/node-status to
acceptance/cli/node-status. The acceptance roachtests are all going to
share the same cluster to amortize the cluster setup/teardown time.

Fun fact: the acceptance/build-info roachtest is about twice as fast as
the old build-info acceptance test.

See cockroachdb#29151

Release note: None
  • Loading branch information
petermattis committed Sep 5, 2018
1 parent d713fbe commit bb9c340
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 58 deletions.
2 changes: 1 addition & 1 deletion build/teamcity-local-roachtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tc_end_block "Compile workload/roachtest"

tc_start_block "Run local roachtests"
# TODO(peter,dan): curate a suite of the tests that works locally.
run build/builder.sh ./bin/roachtest run '(cli|kv/splits)' \
run build/builder.sh ./bin/roachtest run '(acceptance|kv/splits)' \
--local \
--cockroach "cockroach" \
--workload "bin/workload" \
Expand Down
42 changes: 42 additions & 0 deletions pkg/cmd/roachtest/acceptance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2018 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

package main

import "context"

func registerAcceptance(r *registry) {
spec := testSpec{
Name: "acceptance",
Nodes: nodes(3),
}

testCases := []struct {
name string
fn func(ctx context.Context, t *test, c *cluster)
}{
{"build-info", runBuildInfo},
{"cli/node-status", runCLINodeStatus},
}
for _, tc := range testCases {
spec.SubTests = append(spec.SubTests, testSpec{
Name: tc.name,
Stable: true, // DO NOT COPY to new tests
Run: tc.fn,
})
}

r.Add(spec)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015 The Cockroach Authors.
// Copyright 2018 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -10,48 +10,31 @@
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

package acceptance
package main

import (
"context"
"testing"
"time"
"net/http"

"github.com/cockroachdb/cockroach/pkg/acceptance/cluster"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/util/httputil"
"github.com/cockroachdb/cockroach/pkg/util/log"
)

func TestBuildInfo(t *testing.T) {
s := log.Scope(t)
defer s.Close(t)
func runBuildInfo(ctx context.Context, t *test, c *cluster) {
c.Put(ctx, cockroach, "./cockroach", c.All())
c.Wipe(ctx)
c.Start(ctx)

RunLocal(t, func(t *testing.T) {
runTestWithCluster(t, testBuildInfoInner)
})
}

func testBuildInfoInner(
ctx context.Context, t *testing.T, c cluster.Cluster, cfg cluster.TestConfig,
) {
if err := CheckGossip(ctx, c, 20*time.Second, HasPeers(c.NumNodes())); err != nil {
var details serverpb.DetailsResponse
url := `http://` + c.ExternalAdminUIAddr(ctx, c.Node(1))[0] + `/_status/details/local`
err := httputil.GetJSON(http.Client{}, url, &details)
if err != nil {
t.Fatal(err)
}

var details serverpb.DetailsResponse
testutils.SucceedsSoon(t, func() error {
select {
case <-stopper.ShouldStop():
t.Fatalf("interrupted")
default:
}
return httputil.GetJSON(cluster.HTTPClient, c.URL(ctx, 0)+"/_status/details/local", &details)
})

bi := details.BuildInfo
testData := map[string]string{
"go_version": bi.GoVersion,
Expand All @@ -61,7 +44,7 @@ func testBuildInfoInner(
}
for key, val := range testData {
if val == "" {
t.Errorf("build info not set for \"%s\"", key)
t.Fatalf("build info not set for \"%s\"", key)
}
}
}
27 changes: 2 additions & 25 deletions pkg/cmd/roachtest/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (

func runCLINodeStatus(ctx context.Context, t *test, c *cluster) {
c.Put(ctx, cockroach, "./cockroach", c.All())
c.Start(ctx, c.All())
c.Wipe(ctx)
c.Start(ctx)

db := c.Conn(ctx, 1)
defer db.Close()
Expand Down Expand Up @@ -82,27 +83,3 @@ func runCLINodeStatus(ctx context.Context, t *test, c *cluster) {
}
}
}

func registerCLI(r *registry) {
spec := testSpec{
Name: "cli",
Stable: true, // DO NOT COPY to new tests
Nodes: nodes(3),
}

testCases := []struct {
name string
fn func(ctx context.Context, t *test, c *cluster)
}{
{"node-status", runCLINodeStatus},
}
for _, tc := range testCases {
spec.SubTests = append(spec.SubTests, testSpec{
Name: tc.name,
Stable: true, // DO NOT COPY to new tests
Run: tc.fn,
})
}

r.Add(spec)
}
10 changes: 10 additions & 0 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,16 @@ func (c *cluster) InternalAdminUIAddr(ctx context.Context, node nodeListOption)
return addrs
}

// ExternalAdminUIAddr returns the internal Admin UI address in the form host:port
// for the specified node.
func (c *cluster) ExternalAdminUIAddr(ctx context.Context, node nodeListOption) []string {
var addrs []string
for _, u := range c.ExternalAddr(ctx, node) {
addrs = append(addrs, addrToAdminUIAddr(c, u))
}
return addrs
}

// InternalAddr returns the internal address in the form host:port for the
// specified nodes.
func (c *cluster) InternalAddr(ctx context.Context, node nodeListOption) []string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func registerTests(r *registry) {
//
// grep -h -E 'func register[^(]+\(.*registry\) {' *.go | grep -E -o 'register[^(]+' | grep -E -v '^register(Tests|Benchmarks)$' | grep -v '^\w*Bench$' | sort -f | awk '{printf "\t%s(r)\n", $0}'

registerAcceptance(r)
registerAllocator(r)
registerBackup(r)
registerCancel(r)
registerCDC(r)
registerClearRange(r)
registerCLI(r)
registerClock(r)
registerCopy(r)
registerDebug(r)
Expand Down

0 comments on commit bb9c340

Please sign in to comment.