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

restore: CQL session created out of rpc_addresses #3418

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
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ integration-test:
# Load Minio config for INTEGRATION_TEST_ARGS
include testing/.env

INTEGRATION_TEST_ARGS := -cluster 192.168.100.100 \
-managed-cluster 192.168.100.11,192.168.100.12,192.168.100.13,192.168.100.21,192.168.100.22,192.168.100.23 \
-managed-second-cluster 192.168.100.30 \
INTEGRATION_TEST_ARGS := -cluster 192.168.200.100 \
-managed-cluster 192.168.200.11,192.168.200.12,192.168.200.13,192.168.200.21,192.168.200.22,192.168.200.23 \
-managed-second-cluster 192.168.200.30 \
-user cassandra -password cassandra \
-agent-auth-token token \
-s3-data-dir ./testing/minio/data -s3-provider Minio -s3-endpoint $(MINIO_ENDPOINT) -s3-access-key-id $(MINIO_USER_ACCESS_KEY) -s3-secret-access-key $(MINIO_USER_SECRET_KEY)
Expand All @@ -122,7 +122,7 @@ pkg-integration-test:
@docker kill scylla_manager_server 2> /dev/null || true
@CGO_ENABLED=0 GOOS=linux go test -tags integration -c -o ./integration-test.dev $(PKG)
@docker run --name "scylla_manager_server" \
--network scylla_manager_public \
--network host \
-v "/tmp:/tmp" \
-v "$(PWD)/integration-test.dev:/usr/bin/integration-test:ro" \
-v "$(PWD)/testing:/integration-test/testing" \
Expand Down Expand Up @@ -174,11 +174,12 @@ build-server: ## Build development server
.PHONY: run-server
run-server: build-server ## Build and run development server
@docker run --name "scylla_manager_server" \
--network scylla_manager_public \
--network scylla_manager_second --network scylla_manager_public \
-p "5080:5080" \
-p "5443:5443" \
-p "5090:5090" \
-v "$(PWD)/scylla-manager.dev:/usr/bin/scylla-manager:ro" \
-v "$(PWD)/sctool.dev:/usr/bin/sctool:ro" \
-v "$(PWD)/testing/scylla-manager/scylla-manager.yaml:/etc/scylla-manager/scylla-manager.yaml:ro" \
-v "/tmp:/tmp" \
-i --read-only --rm scylladb/scylla-manager-dev scylla-manager
Expand Down
34 changes: 31 additions & 3 deletions pkg/ping/cqlping/cqlping_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ import (
"testing"
"time"

"github.com/scylladb/go-log"
"github.com/scylladb/scylla-manager/v3/pkg/ping"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
"github.com/scylladb/scylla-manager/v3/pkg/service/cluster"
"github.com/scylladb/scylla-manager/v3/pkg/testutils"
"github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"go.uber.org/zap/zapcore"
)

func TestPingIntegration(t *testing.T) {
user, password := testutils.ManagedClusterCredentials()
client := newTestClient(t, log.NewDevelopmentWithLevel(zapcore.InfoLevel).Named("client"), nil)
defer client.Close()

sessionHosts, err := cluster.GetRPCAddresses(context.Background(), client, []string{db.ManagedClusterHost()})
if err != nil {
t.Fatal(err)
}

user, password := db.ManagedClusterCredentials()
config := Config{
Addr: testutils.ManagedClusterHost() + ":9042",
Addr: sessionHosts[0],
Timeout: 250 * time.Millisecond,
}

Expand Down Expand Up @@ -54,7 +67,7 @@ func TestPingTLSIntegration(t *testing.T) {
t.SkipNow()

config := Config{
Addr: testutils.ManagedClusterHost() + ":9042",
Addr: db.ManagedClusterHost() + ":9042",
Timeout: 250 * time.Millisecond,
TLSConfig: &tls.Config{
InsecureSkipVerify: true,
Expand All @@ -77,3 +90,18 @@ func TestPingTLSIntegration(t *testing.T) {
t.Logf("QueryPing() = %s", d)
})
}

func newTestClient(t *testing.T, logger log.Logger, config *scyllaclient.Config) *scyllaclient.Client {
t.Helper()

if config == nil {
c := scyllaclient.TestConfig(db.ManagedClusterHosts(), testutils.AgentAuthToken())
config = &c
}

c, err := scyllaclient.NewClient(*config, logger)
if err != nil {
t.Fatal(err)
}
return c
}
4 changes: 2 additions & 2 deletions pkg/ping/cqlping/main_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2017 ScyllaDB
// Copyright (C) 2023 ScyllaDB

package cqlping

Expand All @@ -9,5 +9,5 @@ import (
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
}
5 changes: 3 additions & 2 deletions pkg/ping/dynamoping/dynamoping_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
"testing"
"time"

"github.com/scylladb/scylla-manager/v3/pkg/testutils"
_ "github.com/scylladb/scylla-manager/v3/pkg/testutils"
"github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
)

func TestPingIntegration(t *testing.T) {
config := Config{
Addr: "http://" + testutils.ManagedClusterHost() + ":8000",
Addr: "http://" + db.ManagedClusterHost() + ":8000",
Timeout: 250 * time.Millisecond,
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/ping/dynamoping/main_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2017 ScyllaDB
// Copyright (C) 2023 ScyllaDB

package dynamoping

Expand All @@ -9,5 +9,5 @@ import (
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/scylladb/gocqlx/v2/migrate"
"github.com/scylladb/gocqlx/v2/qb"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/pkg/util/uuid"
"github.com/scylladb/scylla-manager/v3/schema"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/scylladb/gocqlx/v2"
"github.com/scylladb/gocqlx/v2/migrate"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/scylladb/gocqlx/v2"
"github.com/scylladb/gocqlx/v2/qb"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/schema"

"github.com/scylladb/gocqlx/v2/migrate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/scylladb/gocqlx/v2"
"github.com/scylladb/gocqlx/v2/migrate"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/scylladb/gocqlx/v2"
"github.com/scylladb/gocqlx/v2/migrate"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/scylladb/gocqlx/v2"
"github.com/scylladb/gocqlx/v2/qb"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/schema"

"github.com/scylladb/gocqlx/v2/migrate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/scylladb/gocqlx/v2"
"github.com/scylladb/gocqlx/v2/migrate"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/schema"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/schema/migrate/migrate_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/scylladb/go-log"
"github.com/scylladb/gocqlx/v2"
"github.com/scylladb/gocqlx/v2/migrate"
"github.com/scylladb/scylla-manager/v3/pkg/testutils"
"github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/schema"
)

Expand All @@ -40,7 +40,7 @@ func testCallback(t *testing.T, ev migrate.CallbackEvent, name string, prepare,

saveRegister()
defer restoreRegister()
session := testutils.CreateSessionWithoutMigration(t)
session := db.CreateSessionWithoutMigration(t)

reg.Add(ev, name, func(ctx context.Context, session gocqlx.Session, ev migrate.CallbackEvent, name string) error {
if err := prepare(session); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/scyllaclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type Client struct {
scyllaOps scyllaOperations.ClientService
agentOps agentOperations.ClientService
client retryableClient
hostPool hostpool.HostPool

mu sync.RWMutex
dcCache map[string]string
Expand Down Expand Up @@ -120,6 +121,7 @@ func NewClient(config Config, logger log.Logger) (*Client, error) {
logger: logger,
scyllaOps: scyllaOps,
agentOps: agentOps,
hostPool: pool,
client: retryableWrapClient(client, rc, logger),
dcCache: make(map[string]string),
}, nil
Expand All @@ -135,6 +137,9 @@ func (c *Client) Close() error {
if t, ok := c.config.Transport.(*http.Transport); ok {
t.CloseIdleConnections()
}
if c.hostPool != nil {
c.hostPool.Close()
}
return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/scyllaclient/client_ping_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/scylladb/go-log"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
)

func TestCheckHostsConnectivityIntegration(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/scyllaclient/client_rclone_agent_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/scylladb/go-log"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
)

var longPollingTimeoutSeconds = 1
Expand Down
13 changes: 7 additions & 6 deletions pkg/scyllaclient/client_scylla_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/scylladb/go-set/i64set"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/pkg/util/slice"
"github.com/scylladb/scylla-manager/v3/pkg/util/timeutc"
)
Expand Down Expand Up @@ -47,12 +48,12 @@ func TestClientStatusIntegration(t *testing.T) {
}

golden := scyllaclient.NodeStatusInfoSlice{
{Datacenter: "dc1", Addr: "192.168.100.11", State: "", Status: true},
{Datacenter: "dc1", Addr: "192.168.100.12", State: "", Status: true},
{Datacenter: "dc1", Addr: "192.168.100.13", State: "", Status: true},
{Datacenter: "dc2", Addr: "192.168.100.21", State: "", Status: true},
{Datacenter: "dc2", Addr: "192.168.100.22", State: "", Status: true},
{Datacenter: "dc2", Addr: "192.168.100.23", State: "", Status: true},
{Datacenter: "dc1", Addr: "192.168.200.11", State: "", Status: true},
{Datacenter: "dc1", Addr: "192.168.200.12", State: "", Status: true},
{Datacenter: "dc1", Addr: "192.168.200.13", State: "", Status: true},
{Datacenter: "dc2", Addr: "192.168.200.21", State: "", Status: true},
{Datacenter: "dc2", Addr: "192.168.200.22", State: "", Status: true},
{Datacenter: "dc2", Addr: "192.168.200.23", State: "", Status: true},
}

if diff := cmp.Diff(status, golden, cmpopts.IgnoreFields(scyllaclient.NodeStatusInfo{}, "HostID")); diff != "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/scyllaclient/retry_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/scylladb/go-log"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/pkg/util/httpx"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/service/backup/progress_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"

"github.com/scylladb/scylla-manager/v3/pkg/schema/table"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils"
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db"
"github.com/scylladb/scylla-manager/v3/pkg/util/uuid"
)

Expand Down
Loading