schema_version_reader.go ×4

Frontier kind: Joint frontier

unlabeled · c_a5ddcb6b13c4

1 test · 2918 LOC · 124 files · introduces 1 test · 77 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges77 lines · 3 files
Tests
1 test

Contains — complete concept membership

All code (extent)
524 ranges2918 lines · 124 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 77 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/tools/cassandra/version_tests.go 48 introduced LOC · 4 ranges

Open complete file

23 )
24
25 > func (s *VersionTestSuite) SetupTest() { version_tests.go
26 > s.Assertions = require.New(s.T()) // Have to define our overridden assertions in the test setup. If we did it earlier, s.T() will return nil
27 > }
28
29 > func (s *VersionTestSuite) TestVerifyCompatibleVersion() { version_tests.go
30 > keyspace := "temporal_ver_test_"
31 > _, filename, _, ok := runtime.Caller(0)
32 > s.True(ok)
33 > root := path.Dir(path.Dir(path.Dir(filename)))
34 > cqlFile := path.Join(root, "schema/cassandra/temporal/schema.cql")
35 >
36 > defer s.createKeyspace(keyspace)()
37 > s.NoError(RunTool([]string{
38 > "./tool", "-k", keyspace, "-q", "setup-schema", "-f", cqlFile, "-version", "10.0", "-o",
39 > }))
40 >
41 > defaultCfg := config.Cassandra{
42 > Hosts: environment.GetCassandraAddress(),
43 > Port: environment.GetCassandraPort(),
44 > User: "",
45 > Password: "",
46 > Keyspace: keyspace,
47 > }
48 > cfg := config.Persistence{
49 > DefaultStore: "default",
50 > DataStores: map[string]config.DataStore{
51 > "default": {Cassandra: &defaultCfg},
52 > },
53 > TransactionSizeLimit: dynamicconfig.GetIntPropertyFn(primitives.DefaultTransactionSizeLimit),
54 > }
55 > s.NoError(cassandra.VerifyCompatibleVersion(cfg, resolver.NewNoopResolver(), log.NewNoopLogger()))
56 > }
57
58 > func (s *VersionTestSuite) createKeyspace(keyspace string) func() { version_tests.go
59 > cfg := &CQLClientConfig{
60 > Hosts: environment.GetCassandraAddress(),
61 > Port: environment.GetCassandraPort(),
62 > Keyspace: "system",
63 > Timeout: defaultTimeout,
64 > numReplicas: 1,
65 > }
66 > client, err := newCQLClient(cfg, log.NewNoopLogger())
67 > s.NoError(err)
68 >
69 > err = client.createKeyspace(keyspace)
70 > if err != nil {
71 s.Fail("error creating keyspace, err=%v", err)
72 }
73 > return func() { version_tests.go
74 > s.NoError(client.dropKeyspace(keyspace))
75 > client.Close()
76 > }
77 }
go.temporal.io/server/common/persistence/cassandra/schema_version_reader.go 15 introduced LOC · 4 ranges

Open complete file

17 )
18
19 > func NewSchemaVersionReader(session gocql.Session) *SchemaVersionReader { schema_version_reader.go
20 > return &SchemaVersionReader{
21 > session: session,
22 > }
23 > }
24
25 // ReadSchemaVersion returns the current schema version for the Keyspace
26 > func (svr *SchemaVersionReader) ReadSchemaVersion(keyspace string) (string, error) { schema_version_reader.go
27 > query := svr.session.Query(readSchemaVersionCQL, keyspace)
28 >
29 > iter := query.Iter()
30 > var version string
31 > success := iter.Scan(&version)
32 > err := iter.Close()
33 > if err == nil && !success {
34 err = fmt.Errorf("no schema version found for keyspace %q", keyspace)
35 }
36 > if err != nil { schema_version_reader.go
37 return "", fmt.Errorf("unable to get current schema version from Cassandra: %w", err)
38 }
39
40 > return version, nil schema_version_reader.go
41 }
go.temporal.io/server/common/persistence/cassandra/version_checker.go 14 introduced LOC · 4 ranges

Open complete file

32 ds, ok := cfg.DataStores[cfg.DefaultStore]
33 if ok && ds.Cassandra != nil {
34 > return CheckCompatibleVersion(*ds.Cassandra, r, cassandraschema.Version, logger) version_checker.go
35 > }
36 return nil
37 }
43 expectedVersion string,
44 logger log.Logger,
45 > ) error { version_checker.go
46 >
47 > session, err := commongocql.NewSession(
48 > func() (*gocql.ClusterConfig, error) {
49 > return commongocql.NewCassandraCluster(cfg, r)
50 > },
51 logger,
52 metrics.NoopMetricsHandler,
53 )
54 > if err != nil { version_checker.go
55 return err
56 }
57 > defer session.Close() version_checker.go
58 >
59 > schemaVersionReader := NewSchemaVersionReader(session)
60 >
61 > return schema.VerifyCompatibleVersion(schemaVersionReader, cfg.Keyspace, expectedVersion)
62 }