MCPcopy
hub / github.com/grafana/tempo / runTempoHarness

Function runTempoHarness

integration/util/harness.go:222–282  ·  view source on GitHub ↗

runTempoHarness is the internal implementation that sets up and runs a single harness instance

(t *testing.T, harnessCfg TestHarnessConfig, requestedBackend string, testFunc func(*TempoHarness))

Source from the content-addressed store, hash-verified

220
221// runTempoHarness is the internal implementation that sets up and runs a single harness instance
222func runTempoHarness(t *testing.T, harnessCfg TestHarnessConfig, requestedBackend string, testFunc func(*TempoHarness)) {
223 t.Helper()
224
225 // Create scenario with normalized test name
226 name := normalizeTestName(t.Name())
227 s, err := e2e.NewScenario("e2e_" + name)
228 require.NoError(t, err)
229 defer s.Close()
230
231 harness := &TempoHarness{
232 Services: map[string]*e2e.HTTPService{},
233 TestScenario: s,
234 readinessProbe: harnessCfg.ReadinessProbe,
235 }
236
237 // Setup config and infrastructure
238 tempoCfg := setupConfig(t, s, &harnessCfg, requestedBackend, harness)
239
240 // Start object storage backend if not using local filesystem
241 if tempoCfg.StorageConfig.Trace.Backend != backend.Local {
242 backend, err := startBackend(t, s, tempoCfg)
243 require.NoError(t, err, "failed to start backend")
244 harness.Services[ServiceObjectStorage] = backend
245 }
246
247 // bail out here if we don't need any tempo components
248 if harnessCfg.DeploymentMode == DeploymentModeNone {
249 return
250 }
251
252 components := harnessCfg.Components
253 if harnessCfg.DeploymentMode == DeploymentModeSingleBinary {
254 components &^= componentsKafka | componentsBlockBuilder
255 }
256
257 // Start Kafka
258 // todo: should we add a field to reference kafka on the harness? not needed atm. maybe to test failure states by stopping it?
259 if components&componentsKafka != 0 {
260 kafka := e2edb.NewKafka()
261 require.NoError(t, s.StartAndWaitReady(kafka), "failed to start Kafka")
262 }
263
264 if components&componentsPrometheus != 0 {
265 prometheus := newPrometheus()
266 require.NoError(t, s.StartAndWaitReady(prometheus), "failed to start prometheus")
267 harness.Services[ServicePrometheus] = prometheus
268 }
269
270 // Start Tempo services based on deployment mode
271 switch harnessCfg.DeploymentMode {
272 case DeploymentModeSingleBinary:
273 require.NoError(t, harness.startSingleBinary(t), "failed to start single binary")
274 case DeploymentModeMicroservices:
275 require.NoError(t, harness.startMicroservices(t, harnessCfg), "failed to start microservices")
276 default:
277 panic(fmt.Sprintf("unknown deployment mode: %d", harnessCfg.DeploymentMode))
278 }
279

Callers 1

RunIntegrationTestsFunction · 0.85

Calls 8

startSingleBinaryMethod · 0.95
startMicroservicesMethod · 0.95
normalizeTestNameFunction · 0.85
setupConfigFunction · 0.85
startBackendFunction · 0.85
newPrometheusFunction · 0.85
NameMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected