diff --git a/integration/querier_test.go b/integration/querier_test.go index e450d1c486..dddddccd16 100644 --- a/integration/querier_test.go +++ b/integration/querier_test.go @@ -485,17 +485,17 @@ func TestQuerierWithBlocksStorageRunningInSingleBinaryMode(t *testing.T) { require.NoError(t, err) require.Equal(t, model.ValVector, result.Type()) assert.Equal(t, expectedVector1, result.(model.Vector)) - expectedCacheRequests += seriesReplicationFactor * 4 // expanded postings, postings, series (retrieving labels and then while streaming chunks) - expectedCacheHits += seriesReplicationFactor // one for each series (for chunks) - expectedMemcachedOps += seriesReplicationFactor * (3*2 + 1) // Same reasoning as for expectedCacheRequests, but this also includes a set for each get that is not a hit + expectedCacheRequests += seriesReplicationFactor * 4 // expanded postings, postings, series (retrieving labels and then while streaming chunks) + expectedCacheHits += seriesReplicationFactor // one for each series (while streaming chunks) + expectedMemcachedOps += (seriesReplicationFactor * 4) + (seriesReplicationFactor * 3) // Same reasoning as for expectedCacheRequests, but this also includes a set for each get that is not a hit result, err = c.Query(series2Name, series2Timestamp) require.NoError(t, err) require.Equal(t, model.ValVector, result.Type()) assert.Equal(t, expectedVector2, result.(model.Vector)) - expectedCacheRequests += seriesReplicationFactor*4 + seriesReplicationFactor // expanded postings, postings, series for 1 time range; only expanded postings for another - expectedCacheHits += seriesReplicationFactor // one for each series - expectedMemcachedOps += seriesReplicationFactor * (4 + 3 + 1) // Same reasoning as for expectedCacheRequests, but this also includes a set for each get that is not a hit + expectedCacheRequests += seriesReplicationFactor*4 + seriesReplicationFactor // expanded postings, postings, series for 1 time range; only expanded postings for another + expectedCacheHits += seriesReplicationFactor // one for each series (while streaming chunks) + expectedMemcachedOps += (seriesReplicationFactor * 4) + (seriesReplicationFactor * 3) // Same reasoning as for expectedCacheRequests, but this also includes a set for each get that is not a hit result, err = c.Query(series3Name, series3Timestamp) require.NoError(t, err) @@ -505,18 +505,18 @@ func TestQuerierWithBlocksStorageRunningInSingleBinaryMode(t *testing.T) { expectedMemcachedOps += seriesReplicationFactor * 2 // Check the in-memory index cache metrics (in the store-gateway). - require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheRequests)), "thanos_store_index_cache_requests_total")) - require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheHits)), "thanos_store_index_cache_hits_total")) // no cache hit cause the cache was empty + require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheRequests)), "thanos_store_index_cache_requests_total"), "expected %v requests", expectedCacheRequests) + require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheHits)), "thanos_store_index_cache_hits_total"), "expected %v hits", expectedCacheHits) if testCfg.indexCacheBackend == tsdb.IndexCacheBackendInMemory { require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64((2*2+2+3)*seriesReplicationFactor)), "thanos_store_index_cache_items")) // 2 series both for postings and series cache, 2 expanded postings on one block, 3 on another one require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64((2*2+2+3)*seriesReplicationFactor)), "thanos_store_index_cache_items_added_total")) // 2 series both for postings and series cache, 2 expanded postings on one block, 3 on another one } else if testCfg.indexCacheBackend == tsdb.IndexCacheBackendMemcached { - require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedMemcachedOps)), "thanos_memcached_operations_total")) + require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedMemcachedOps)), "thanos_memcached_operations_total"), "expected %v operations", expectedMemcachedOps) } // Query back again the 1st series from storage. This time it should use the index cache. // It should get a hit on expanded postings; this means that it will not request individual postings for matchers. - // It should get two hits on series (once for the labels, and again for the chunks). + // It should get two hits on series (once for the labels, and again for the labels when streaming chunks). // We expect 3 cache requests and 3 cache hits. result, err = c.Query(series1Name, series1Timestamp) require.NoError(t, err) @@ -526,14 +526,14 @@ func TestQuerierWithBlocksStorageRunningInSingleBinaryMode(t *testing.T) { expectedCacheHits += seriesReplicationFactor * 3 expectedMemcachedOps += seriesReplicationFactor * 2 // there is no set after the gets this time - require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheRequests)), "thanos_store_index_cache_requests_total")) - require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheHits)), "thanos_store_index_cache_hits_total")) // this time has used the index cache + require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheRequests)), "thanos_store_index_cache_requests_total"), "expected %v requests", expectedCacheRequests) + require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedCacheHits)), "thanos_store_index_cache_hits_total"), "expected %v hits", expectedCacheHits) // this time has used the index cache if testCfg.indexCacheBackend == tsdb.IndexCacheBackendInMemory { require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64((2*2+2+3)*seriesReplicationFactor)), "thanos_store_index_cache_items")) // as before require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64((2*2+2+3)*seriesReplicationFactor)), "thanos_store_index_cache_items_added_total")) // as before } else if testCfg.indexCacheBackend == tsdb.IndexCacheBackendMemcached { - require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedMemcachedOps)), "thanos_memcached_operations_total")) + require.NoError(t, cluster.WaitSumMetrics(e2e.Equals(float64(expectedMemcachedOps)), "thanos_memcached_operations_total"), "expected %v operations", expectedMemcachedOps) } // Query metadata.