Skip to content

Commit afd34e8

Browse files
committed
chore: update tests
Signed-off-by: Timur Tuktamyshev <timur.tuktamyshev@flant.com>
1 parent e4a94e1 commit afd34e8

File tree

2 files changed

+2
-87
lines changed

2 files changed

+2
-87
lines changed

pkg/metrics/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ func InitMetrics(prefix string) {
103103
// ============================================================================
104104
TasksQueueActionDurationSeconds = ReplacePrefix(TasksQueueActionDurationSeconds, prefix)
105105
TasksQueueLength = ReplacePrefix(TasksQueueLength, prefix)
106-
TasksQueueCompactionInQueueTasks = ReplacePrefix(TasksQueueCompactionInQueueTasks, prefix)
107-
TasksQueueCompactionReached = ReplacePrefix(TasksQueueCompactionReached, prefix)
106+
TasksQueueCompactionOperationsTotal = ReplacePrefix(TasksQueueCompactionOperationsTotal, prefix)
107+
TasksQueueCompactionTasksByHook = ReplacePrefix(TasksQueueCompactionTasksByHook, prefix)
108108

109109
// ============================================================================
110110
// Hook Execution Metrics

pkg/task/queue/task_counter_test.go

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,91 +10,6 @@ import (
1010
"github.com/flant/shell-operator/pkg/metrics"
1111
)
1212

13-
// func TestTaskCounterRemoveUsesQueueName(t *testing.T) {
14-
// metricStorage := metric.NewStorageMock(t)
15-
16-
// type gaugeCall struct {
17-
// metric string
18-
// value float64
19-
// labels map[string]string
20-
// }
21-
22-
// var (
23-
// mu sync.Mutex
24-
// calls []gaugeCall
25-
// )
26-
27-
// metricStorage.GaugeSetMock.Set(func(metric string, value float64, labels map[string]string) {
28-
// cloned := make(map[string]string, len(labels))
29-
// for k, v := range labels {
30-
// cloned[k] = v
31-
// }
32-
33-
// mu.Lock()
34-
// calls = append(calls, gaugeCall{
35-
// metric: metric,
36-
// value: value,
37-
// labels: cloned,
38-
// })
39-
// mu.Unlock()
40-
// })
41-
42-
// tc := NewTaskCounter("main", nil, metricStorage)
43-
44-
// testTask := task.NewTask(task_metadata.HookRun).
45-
// WithCompactionID("test-hook")
46-
47-
// tc.Add(testTask)
48-
// tc.Remove(testTask)
49-
50-
// mu.Lock()
51-
// require.NotEmpty(t, calls)
52-
// lastCall := calls[len(calls)-1]
53-
// mu.Unlock()
54-
55-
// require.Equal(t, metrics.TasksQueueCompactionInQueueTasks, lastCall.metric)
56-
// require.Equal(t, float64(0), lastCall.value)
57-
// require.Equal(t, "main", lastCall.labels["queue_name"])
58-
// require.Equal(t, "test-hook", lastCall.labels["task_id"])
59-
// }
60-
61-
// func TestTaskCounterRemoveClearsReachedCap(t *testing.T) {
62-
// metricStorage := metric.NewStorageMock(t)
63-
64-
// var (
65-
// mu sync.Mutex
66-
// reachedValues []float64
67-
// )
68-
69-
// metricStorage.GaugeSetMock.Set(func(metric string, value float64, labels map[string]string) {
70-
// if metric == metrics.TasksQueueCompactionReached {
71-
// mu.Lock()
72-
// reachedValues = append(reachedValues, value)
73-
// mu.Unlock()
74-
// }
75-
// })
76-
77-
// tc := NewTaskCounter("main", nil, metricStorage)
78-
79-
// testTask := task.NewTask(task_metadata.HookRun).
80-
// WithCompactionID("test-hook")
81-
82-
// for i := 0; i < taskCap; i++ {
83-
// tc.Add(testTask)
84-
// }
85-
86-
// require.True(t, tc.IsAnyCapReached())
87-
88-
// tc.Remove(testTask)
89-
90-
// require.False(t, tc.IsAnyCapReached())
91-
92-
// mu.Lock()
93-
// require.NotEmpty(t, reachedValues)
94-
// require.Equal(t, float64(0), reachedValues[len(reachedValues)-1])
95-
// mu.Unlock()
96-
// }
97-
9813
func TestTaskCounterUpdateHookMetricsFromSnapshot(t *testing.T) {
9914
metricStorage := metric.NewStorageMock(t)
10015

0 commit comments

Comments
 (0)