(t *testing.T)
| 5053 | } |
| 5054 | |
| 5055 | func TestIngester_flushing(t *testing.T) { |
| 5056 | for name, tc := range map[string]struct { |
| 5057 | setupIngester func(cfg *Config) |
| 5058 | action func(t *testing.T, i *Ingester, reg *prometheus.Registry) |
| 5059 | }{ |
| 5060 | "ingesterShutdown": { |
| 5061 | setupIngester: func(cfg *Config) { |
| 5062 | cfg.BlocksStorageConfig.TSDB.FlushBlocksOnShutdown = true |
| 5063 | cfg.BlocksStorageConfig.TSDB.KeepUserTSDBOpenOnShutdown = true |
| 5064 | }, |
| 5065 | action: func(t *testing.T, i *Ingester, reg *prometheus.Registry) { |
| 5066 | pushSingleSampleWithMetadata(t, i) |
| 5067 | |
| 5068 | // Nothing shipped yet. |
| 5069 | require.NoError(t, testutil.GatherAndCompare(reg, bytes.NewBufferString(` |
| 5070 | # HELP cortex_ingester_shipper_uploads_total Total number of uploaded TSDB blocks |
| 5071 | # TYPE cortex_ingester_shipper_uploads_total counter |
| 5072 | cortex_ingester_shipper_uploads_total 0 |
| 5073 | `), "cortex_ingester_shipper_uploads_total")) |
| 5074 | |
| 5075 | // Shutdown ingester. This triggers flushing of the block. |
| 5076 | require.NoError(t, services.StopAndAwaitTerminated(context.Background(), i)) |
| 5077 | |
| 5078 | verifyCompactedHead(t, i, true) |
| 5079 | |
| 5080 | // Verify that block has been shipped. |
| 5081 | require.NoError(t, testutil.GatherAndCompare(reg, bytes.NewBufferString(` |
| 5082 | # HELP cortex_ingester_shipper_uploads_total Total number of uploaded TSDB blocks |
| 5083 | # TYPE cortex_ingester_shipper_uploads_total counter |
| 5084 | cortex_ingester_shipper_uploads_total 1 |
| 5085 | `), "cortex_ingester_shipper_uploads_total")) |
| 5086 | }, |
| 5087 | }, |
| 5088 | |
| 5089 | "shutdownHandler": { |
| 5090 | setupIngester: func(cfg *Config) { |
| 5091 | cfg.BlocksStorageConfig.TSDB.FlushBlocksOnShutdown = false |
| 5092 | cfg.BlocksStorageConfig.TSDB.KeepUserTSDBOpenOnShutdown = true |
| 5093 | }, |
| 5094 | |
| 5095 | action: func(t *testing.T, i *Ingester, reg *prometheus.Registry) { |
| 5096 | pushSingleSampleWithMetadata(t, i) |
| 5097 | |
| 5098 | // Nothing shipped yet. |
| 5099 | require.NoError(t, testutil.GatherAndCompare(reg, bytes.NewBufferString(` |
| 5100 | # HELP cortex_ingester_shipper_uploads_total Total number of uploaded TSDB blocks |
| 5101 | # TYPE cortex_ingester_shipper_uploads_total counter |
| 5102 | cortex_ingester_shipper_uploads_total 0 |
| 5103 | `), "cortex_ingester_shipper_uploads_total")) |
| 5104 | |
| 5105 | i.ShutdownHandler(httptest.NewRecorder(), httptest.NewRequest("POST", "/shutdown", nil)) |
| 5106 | |
| 5107 | verifyCompactedHead(t, i, true) |
| 5108 | require.NoError(t, testutil.GatherAndCompare(reg, bytes.NewBufferString(` |
| 5109 | # HELP cortex_ingester_shipper_uploads_total Total number of uploaded TSDB blocks |
| 5110 | # TYPE cortex_ingester_shipper_uploads_total counter |
| 5111 | cortex_ingester_shipper_uploads_total 1 |
| 5112 | `), "cortex_ingester_shipper_uploads_total")) |
nothing calls this directly
no test coverage detected