179
180
// newTemporal returns an instance that hosts full temporal in one process
181
>
func newTemporal(t *testing.T, params *temporalParams) *temporalImpl {
onebox.go
182
>
impl := &temporalImpl{
183
>
logger: params.logger,
184
>
clusterMetadataConfig: params.clusterMetadataConfig,
185
>
persistenceConfig: params.persistenceConfig,
186
>
metadataMgr: params.metadataMgr,
187
>
clusterMetadataMgr: params.clusterMetadataManager,
188
>
shardMgr: params.shardMgr,
189
>
taskMgr: params.taskMgr,
190
>
executionManager: params.executionManager,
191
>
namespaceReplicationQueue: params.namespaceReplicationQueue,
192
>
abstractDataStoreFactory: params.abstractDataStoreFactory,
193
>
visibilityStoreFactory: params.visibilityStoreFactory,
194
>
esConfig: params.esConfig,
195
>
esClient: params.esClient,
196
>
archiverMetadata: params.archiverMetadata,
197
>
archiverProvider: params.archiverProvider,
198
>
frontendConfig: params.frontendConfig,
199
>
historyConfig: params.historyConfig,
200
>
matchingConfig: params.matchingConfig,
201
>
workerConfig: params.workerConfig,
202
>
mockAdminClient: params.mockAdminClient,
203
>
namespaceReplicationTaskExecutor: params.namespaceReplicationTaskExecutor,
204
>
dcRedirectionPolicy: params.dcRedirectionPolicy,
205
>
tlsConfigProvider: params.tlsConfigProvider,
206
>
captureMetricsHandler: params.captureMetricsHandler,
207
>
dcClient: dynamicconfig.NewMemoryClient(),
208
>
testHooks: testhooks.NewTestHooks(),
209
>
serviceFxOptions: params.serviceFxOptions,
210
>
taskCategoryRegistry: params.taskCategoryRegistry,
211
>
hostsByProtocolByService: params.hostsByProtocolByService,
212
>
replicationStreamRecorder: NewReplicationStreamRecorder(),
213
>
spanExporters: params.spanExporters,
214
>
tokenProvider: params.tokenProvider,
215
>
enableHistoryTaskRecorder: params.enableHistoryTaskRecorder,
216
>
}
217
>
218
>
// Configure output file path for on-demand logging (call WriteToLog() to write)
219
>
clusterName := params.clusterMetadataConfig.CurrentClusterName
220
>
outputFile := fmt.Sprintf("/tmp/replication_stream_messages_%s.txt", clusterName)
221
>
impl.replicationStreamRecorder.SetOutputFile(outputFile)
222
>
impl.clients = newClients(
223
>
impl.logger,
224
>
impl.hostsByProtocolByService[grpcProtocol],
225
>
&impl.frontendMembershipAddress,
226
>
impl.tlsConfigProvider,
227
>
impl.GetMetricsHandler(),
228
>
impl.dcClient,
229
>
impl.testHooks,
230
>
impl.historyConfig.NumHistoryShards,
231
>
impl.metadataMgr,
232
>
impl.tokenProvider,
233
>
)
234
>
235
>
// Global defaults: applied without cleanup so they persist across cluster reuse.
236
>
for k, v := range defaultDynamicConfigOverrides {
237
>
impl.overrideDynamicConfigForClusterLifetime(k, v)
238
>
}
239
// Override Nexus callback URL. This is parameterized on the frontend's HTTP address,
240
// so it can't be overriden in the loop above.
242
>
// Per-test overrides: cleaned up when the creating test finishes.
243
>
for k, v := range params.dynamicConfigOverrides {
244
impl.overrideDynamicConfigForTest(t, k, v)
245
}
247
}
248
249
>
func (c *temporalImpl) Start() error {
onebox.go
250
>
// create temporal-system namespace, this must be created before starting
251
>
// the services - so directly use the metadataManager to create this
252
>
if err := c.createSystemNamespace(); err != nil {
253
return err
254
}
256
>
c.startHistory()
257
>
c.startFrontend()
258
>
c.startWorker()
259
>
260
>
return nil
261
}
262
263
>
func (c *temporalImpl) Stop() error {
onebox.go
264
>
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
265
>
defer cancel()
266
>
267
>
var errs []error
268
>
errs = append(errs, c.close()...)
269
>
270
>
slices.Reverse(c.fxApps) // less log spam if we go backwards
271
>
for _, app := range c.fxApps {
272
>
errs = append(errs, app.Stop(ctx))
273
>
}
274
275
>
return multierr.Combine(errs...)
onebox.go
276
}
277
278
>
func (c *temporalImpl) makeHostMap(serviceName primitives.ServiceName, self string) map[primitives.ServiceName]static.Hosts {
onebox.go
279
>
hostMap := maps.Clone(c.hostsByProtocolByService[grpcProtocol])
280
>
hosts := hostMap[serviceName]
281
>
hosts.Self = self
282
>
hostMap[serviceName] = hosts
283
>
return hostMap
284
>
}
285
286
// Use this to get an address for a remote cluster to connect to.