Files
Zach LeslieandGitHub 654ffd99e8 Improve backendscheduler performance and integrity (#5106)
* [provider/compaction] Replace HasBlocks with specific implementation

* [backendscheduler/work] drop OnBlock and HasBlocks interface and usage

* [backendscheduler] refactor job replay on top of blocklist

* Unlock early while sorting results

* [backendscheduler] relay worklist on top of blocklist on startup

* Break inner loop based on previous PR feedback

* Rename empty job metric
2025-05-22 15:05:14 +00:00

66 lines
1.2 KiB
Go

package work
import (
"testing"
"github.com/google/uuid"
"github.com/grafana/tempo/pkg/tempopb"
"github.com/stretchr/testify/require"
)
var tenant = "test"
func TestStatus(t *testing.T) {
j := &Job{
ID: uuid.NewString(),
}
require.Equal(t, j.GetID(), j.ID)
require.False(t, j.IsFailed())
require.False(t, j.IsComplete())
require.False(t, j.IsRunning())
require.True(t, j.IsPending())
j.Start()
require.True(t, j.IsRunning())
j.Start()
require.False(t, j.IsFailed())
j.Fail()
require.True(t, j.IsFailed())
j.Complete()
require.False(t, j.IsFailed())
require.True(t, j.IsComplete())
}
func TestCompactionDetail(t *testing.T) {
cases := []struct {
name string
jobType tempopb.JobType
detail tempopb.JobDetail
input []string
expected []string
}{
{
name: "non compaction job",
input: []string{"block1", "block2"},
expected: nil,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
j := &Job{
ID: uuid.NewString(),
Type: tc.jobType,
JobDetail: tc.detail,
}
j.SetCompactionOutput(tc.input)
require.Equal(t, j.GetCompactionOutput(), tc.expected)
})
}
}