test_sql_persistence.go ×12

Frontier kind: Code frontier

unlabeled · c_458cef158bd5

298 tests · 3205 LOC · 159 files · introduces 0 tests · 70 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges70 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
507 ranges3205 lines · 159 files · Browse complete extent
All tests (intent)
298 testsBrowse 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.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

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

2 files ranked by introduced lines: 70 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/sql/test_sql_persistence.go 63 introduced LOC · 12 ranges

Open complete file

42 faultInjection *config.FaultInjection,
43 logger log.Logger,
44 > ) *TestCluster { test_sql_persistence.go
45 > var result TestCluster
46 > result.logger = logger
47 > result.dbName = dbName
48 >
49 > result.schemaDir = schemaDir
50 > result.cfg = config.SQL{
51 > User: username,
52 > Password: password,
53 > ConnectAddr: fmt.Sprintf("%v:%v", host, port),
54 > ConnectProtocol: "tcp",
55 > PluginName: pluginName,
56 > DatabaseName: dbName,
57 > TaskScanPartitions: 4,
58 > ConnectAttributes: connectAttributes,
59 > }
60 >
61 > result.faultInjection = faultInjection
62 > return &result
63 > }
64
65 // DatabaseName from PersistenceTestCluster interface
69
70 // SetupTestDatabase from PersistenceTestCluster interface
71 > func (s *TestCluster) SetupTestDatabase() { test_sql_persistence.go
72 > s.CreateDatabase()
73 >
74 > if s.schemaDir == "" {
75 s.logger.Info("No schema directory provided, skipping schema setup")
76 return
88
89 // Config returns the persistence config for connecting to this test cluster
90 > func (s *TestCluster) Config() config.Persistence { test_sql_persistence.go
91 > cfg := s.cfg
92 > return config.Persistence{
93 > DefaultStore: "test",
94 > VisibilityStore: "test",
95 > DataStores: map[string]config.DataStore{
96 > "test": {SQL: &cfg, FaultInjection: s.faultInjection},
97 > },
98 > TransactionSizeLimit: dynamicconfig.GetIntPropertyFn(primitives.DefaultTransactionSizeLimit),
99 > }
100 > }
101
102 // TearDownTestDatabase from PersistenceTestCluster interface
103 > func (s *TestCluster) TearDownTestDatabase() { test_sql_persistence.go
104 > s.DropDatabase()
105 > }
106
107 // CreateDatabase from PersistenceTestCluster interface
108 > func (s *TestCluster) CreateDatabase() { test_sql_persistence.go
109 > cfg2 := s.cfg
110 > // NOTE need to connect with empty name to create new database
111 > if cfg2.PluginName != "sqlite" {
112 cfg2.DatabaseName = ""
113 }
114
115 > db := s.newAdminDB(sqlplugin.DbKindUnknown, &cfg2) test_sql_persistence.go
116 > defer s.closeAdminDB(db)
117 > err := db.CreateDatabase(s.cfg.DatabaseName)
118 > if err != nil {
119 panic(err)
120 }
121 > s.logger.Info("created database", tag.String("database", s.cfg.DatabaseName)) test_sql_persistence.go
122 }
123
124 // DropDatabase from PersistenceTestCluster interface
125 > func (s *TestCluster) DropDatabase() { test_sql_persistence.go
126 > cfg2 := s.cfg
127 >
128 > if cfg2.PluginName == "sqlite" && cfg2.DatabaseName != ":memory:" && cfg2.ConnectAttributes["mode"] != "memory" {
129 if len(cfg2.DatabaseName) > 3 { // 3 should mean not ., .., empty, or /
130 // Remove main database file
198 }
199
200 > func (s *TestCluster) newAdminDB(kind sqlplugin.DbKind, cfg *config.SQL) sqlplugin.AdminDB { test_sql_persistence.go
201 > var db sqlplugin.AdminDB
202 > var err error
203 > err = backoff.ThrottleRetry(
204 > func() error {
205 > db, err = NewSQLAdminDB(kind, cfg, resolver.NewNoopResolver(), log.NewTestLogger(), metrics.NoopMetricsHandler)
206 > return err
207 > },
208 backoff.NewExponentialRetryPolicy(time.Second).WithExpirationInterval(time.Minute),
209 nil,
210 )
211 > if err != nil { test_sql_persistence.go
212 s.logger.Fatal("NewSQLAdminDB", tag.Error(err))
213 }
214 > return db test_sql_persistence.go
215 }
216
217 > func (s *TestCluster) closeAdminDB(db sqlplugin.AdminDB) { test_sql_persistence.go
218 > if err := db.Close(); err != nil {
219 s.logger.Fatal("Close schema DB", tag.Error(err))
220 }
go.temporal.io/server/common/persistence/persistence-tests/persistence_test_base.go 7 introduced LOC · 4 ranges

Open complete file

137
138 // NewTestBaseWithSQL returns a new persistence test base backed by SQL
139 > func NewTestBaseWithSQL(options *TestBaseOptions) *TestBase { persistence_test_base.go
140 > logger := options.Logger
141 > if logger == nil {
142 logger = log.NewTestLogger()
143 }
144
145 > if options.DBPort == 0 { persistence_test_base.go
146 switch options.SQLDBPluginName {
147 case mysql.PluginName:
155 }
156 }
157 > if options.DBHost == "" { persistence_test_base.go
158 switch options.SQLDBPluginName {
159 case mysql.PluginName:
167 }
168 }
169 > testCluster := sql.NewTestCluster(options.SQLDBPluginName, options.DBName, options.DBUsername, options.DBPassword, options.DBHost, options.DBPort, options.ConnectAttributes, options.SchemaDir, options.FaultInjection, logger) persistence_test_base.go
170 > return NewTestBaseForCluster(testCluster, logger)
171 }
172