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

Function TestRunCheckerSuccess

cmd/tempo-vulture/main_test.go:905–948  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

903}
904
905func TestRunCheckerSuccess(t *testing.T) {
906 seed := time.Date(2008, 1, 1, 12, 0, 0, 0, time.UTC)
907 startTime := time.Date(2007, 1, 1, 12, 0, 0, 0, time.UTC)
908 now := time.Date(2009, 1, 1, 12, 0, 0, 0, time.UTC) // Far in the future to ensure trace is ready
909
910 config := vultureConfiguration{
911 tempoOrgID: "orgID",
912 tempoWriteBackoffDuration: time.Second, // Small value to ensure trace is ready
913 tempoLongWriteBackoffDuration: time.Second,
914 }
915
916 logger = zap.NewNop()
917
918 tickChan := make(chan time.Time, 1)
919 mockTicker := &time.Ticker{C: tickChan}
920
921 // Send the time on the channel to trigger the ticker
922 go func() {
923 tickChan <- now
924 }()
925
926 // Checker function that signals completion
927 mx := sync.Mutex{}
928 checkerCalled := false
929 var checkedInfo *util.TraceInfo
930 checker := func(info *util.TraceInfo, _ *zap.Logger) {
931 mx.Lock()
932 defer mx.Unlock()
933 checkerCalled = true
934 checkedInfo = info
935 }
936
937 selectPastTimestamp := func(_ time.Time) (newStart, ts time.Time, skip bool) {
938 return startTime, seed, false
939 }
940 runChecker(mockTicker, config, selectPastTimestamp, checker, logger)
941 time.Sleep(10 * time.Millisecond)
942
943 mx.Lock()
944 defer mx.Unlock()
945 assert.True(t, checkerCalled)
946 require.NotNil(t, checkedInfo)
947 assert.Equal(t, seed.Unix(), checkedInfo.Timestamp().Unix())
948}
949
950func TestCreateHttpClient(t *testing.T) {
951 testCases := []struct {

Callers

nothing calls this directly

Calls 4

TimestampMethod · 0.95
runCheckerFunction · 0.85
SleepMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected