TestLiveStoreDownscaleHappyPath tests the complete downscale flow where an inactive live-store is properly shut down
(t *testing.T)
| 114 | // TestLiveStoreDownscaleHappyPath tests the complete downscale flow where |
| 115 | // an inactive live-store is properly shut down |
| 116 | func TestLiveStoreDownscaleHappyPath(t *testing.T) { |
| 117 | util.RunIntegrationTests(t, util.TestHarnessConfig{}, func(h *util.TempoHarness) { |
| 118 | // harness creates 2 live stores that own a first partition, shutdown B we don't want it for this test |
| 119 | require.NoError(t, h.Services[util.ServiceLiveStoreZoneB].Stop()) |
| 120 | |
| 121 | // start a new livestore that own a second partition. -1 postfix is important to start a new partition! |
| 122 | liveStorePartition1 := newLiveStore("live-store-zone-a-1", "zone-a") |
| 123 | require.NoError(t, h.TestScenario.StartAndWaitReady(liveStorePartition1)) |
| 124 | |
| 125 | // wait for 2 active partitions |
| 126 | distributor := h.Services[util.ServiceDistributor] |
| 127 | waitActivePartitions(t, distributor, 2) |
| 128 | |
| 129 | // Mark partition as INACTIVE |
| 130 | preparePartitionDownscale(t, http.MethodPost, liveStorePartition1) |
| 131 | |
| 132 | // Prepare for shutdown |
| 133 | req, err := http.NewRequest("POST", "http://"+liveStorePartition1.Endpoint(3200)+"/live-store/prepare-downscale", nil) |
| 134 | require.NoError(t, err) |
| 135 | httpResp, err := http.DefaultClient.Do(req) |
| 136 | require.NoError(t, err) |
| 137 | require.Equal(t, 204, httpResp.StatusCode) |
| 138 | |
| 139 | // Stop inactive live-store |
| 140 | require.NoError(t, liveStorePartition1.Stop()) |
| 141 | |
| 142 | waitActivePartitions(t, distributor, 1) |
| 143 | |
| 144 | // Verify only one active partition remains |
| 145 | partitions := getRingStatus(t, distributor).Partitions |
| 146 | |
| 147 | activeCount := 0 |
| 148 | var activePartition *partitionData |
| 149 | |
| 150 | for _, partition := range partitions { |
| 151 | if partition.State == activePartitionState { |
| 152 | activePartition = &partition |
| 153 | activeCount++ |
| 154 | } |
| 155 | } |
| 156 | require.Equal(t, 1, activeCount) |
| 157 | require.NotNil(t, activePartition) |
| 158 | require.Equal(t, int32(0), activePartition.ID) |
| 159 | require.False(t, activePartition.Corrupted) |
| 160 | require.Equal(t, activePartitionState, activePartition.State) |
| 161 | require.Contains(t, activePartition.OwnerIDs, "live-store-zone-a-0") |
| 162 | }) |
| 163 | } |
| 164 | |
| 165 | func TestLiveStoreLookback(t *testing.T) { |
| 166 | for _, testCase := range []struct { |
nothing calls this directly
no test coverage detected