-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pkg): let other services use config cache
This is the first general step toward fixing #3892. It allows for accessing config cache service from other services. Actually using config cache service will be implemented in separate PRs. Ref #3892
- Loading branch information
1 parent
92775c3
commit 3561c16
Showing
9 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2024 ScyllaDB | ||
|
||
package testutils | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/scylladb/go-log" | ||
"github.com/scylladb/scylla-manager/v3/pkg/config/server" | ||
"github.com/scylladb/scylla-manager/v3/pkg/metrics" | ||
"github.com/scylladb/scylla-manager/v3/pkg/schema/table" | ||
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient" | ||
"github.com/scylladb/scylla-manager/v3/pkg/service/cluster" | ||
"github.com/scylladb/scylla-manager/v3/pkg/service/configcache" | ||
"github.com/scylladb/scylla-manager/v3/pkg/store" | ||
. "github.com/scylladb/scylla-manager/v3/pkg/testutils/db" | ||
"github.com/scylladb/scylla-manager/v3/pkg/util/uuid" | ||
) | ||
|
||
// NewTestConfigCacheSvc creates default config cache service which can be used | ||
// for testing other services relaying on it. | ||
func NewTestConfigCacheSvc(t *testing.T, hosts []string) configcache.ConfigCacher { | ||
t.Helper() | ||
|
||
session := CreateScyllaManagerDBSession(t) | ||
secretsStore := store.NewTableStore(session, table.Secrets) | ||
|
||
clusterSvc, err := cluster.NewService(session, metrics.NewClusterMetrics(), secretsStore, | ||
scyllaclient.DefaultTimeoutConfig(), server.DefaultConfig().ClientCacheTimeout, log.NewDevelopment()) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
scyllaClientProvider := func(context.Context, uuid.UUID) (*scyllaclient.Client, error) { | ||
sc := scyllaclient.TestConfig(hosts, AgentAuthToken()) | ||
sc.Timeout = time.Second | ||
sc.Transport = NewHackableRoundTripper(scyllaclient.DefaultTransport()) | ||
return scyllaclient.NewClient(sc, log.NewDevelopment()) | ||
} | ||
|
||
return configcache.NewService(configcache.DefaultConfig(), clusterSvc, scyllaClientProvider, secretsStore, log.NewDevelopment()) | ||
} |