Skip to content

Commit

Permalink
Fix unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdurham committed Nov 27, 2024
1 parent ee1d4b7 commit 78471ad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions internal/component/prometheus/write/queue/e2e_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const alloyMetadataRetried = "alloy_queue_metadata_network_retried"

const alloyNetworkTimestamp = "alloy_queue_series_network_timestamp_seconds"

const alloyDrift = "alloy_queue_series_timestamp_drift_seconds"

// TestMetadata is the large end to end testing for the queue based wal, specifically for metadata.
func TestMetadata(t *testing.T) {
// Check assumes you are checking for any value that is not 0.
Expand Down Expand Up @@ -228,6 +230,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
{
Expand Down Expand Up @@ -270,6 +276,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
// histograms
Expand Down Expand Up @@ -353,6 +363,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
{
Expand Down Expand Up @@ -395,6 +409,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
// TURNING OFF EXEMPLAR TESTS until underlying issue is resolved.
Expand Down
8 changes: 4 additions & 4 deletions internal/component/prometheus/write/queue/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func handlePost(t *testing.T, _ http.ResponseWriter, r *http.Request) ([]prompb.
}

func makeSeries(index int) (int64, float64, labels.Labels) {
return time.Now().UTC().Unix(), float64(index), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index))
return time.Now().UTC().UnixMilli(), float64(index), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index))
}

func makeMetadata(index int) (metadata.Metadata, labels.Labels) {
Expand All @@ -246,13 +246,13 @@ func makeMetadata(index int) (metadata.Metadata, labels.Labels) {
}

func makeHistogram(index int) (int64, labels.Labels, *histogram.Histogram) {
return time.Now().UTC().Unix(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), hist(index)
return time.Now().UTC().UnixMilli(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), hist(index)
}

func makeExemplar(index int) exemplar.Exemplar {
return exemplar.Exemplar{
Labels: labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)),
Ts: time.Now().Unix(),
Ts: time.Now().UnixMilli(),
HasTs: true,
Value: float64(index),
}
Expand Down Expand Up @@ -305,7 +305,7 @@ func histSpanSame(t *testing.T, h []histogram.Span, pb []prompb.BucketSpan) {
}

func makeFloatHistogram(index int) (int64, labels.Labels, *histogram.FloatHistogram) {
return time.Now().UTC().Unix(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), histFloat(index)
return time.Now().UTC().UnixMilli(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), histFloat(index)
}

func histFloat(i int) *histogram.FloatHistogram {
Expand Down

0 comments on commit 78471ad

Please sign in to comment.