public async Task MaintainOnlyOldIndexesWithPartialAliasesAsync() { using (TestSystemClock.Install()) { SystemClock.Test.SetFixedTime(SystemClock.UtcNow.EndOfYear()); var index = new MonthlyEmployeeIndex(_configuration, 1) { MaxIndexAge = SystemClock.UtcNow.EndOfMonth() - SystemClock.UtcNow.SubtractMonths(12).StartOfMonth() }; await index.EnsureIndexAsync(SystemClock.UtcNow.SubtractMonths(11)); await index.EnsureIndexAsync(SystemClock.UtcNow.SubtractMonths(12)); var existsResponse = await _client.IndexExistsAsync(index.GetIndex(SystemClock.UtcNow.SubtractMonths(12))); _logger.Trace(() => existsResponse.GetRequest()); Assert.True(existsResponse.IsValid); Assert.True(existsResponse.Exists); index.MaxIndexAge = SystemClock.UtcNow.EndOfMonth() - SystemClock.UtcNow.StartOfMonth(); await DeleteAliasesAsync(index.GetVersionedIndex(SystemClock.UtcNow.SubtractMonths(12))); await index.MaintainAsync(); existsResponse = await _client.IndexExistsAsync(index.GetIndex(SystemClock.UtcNow.SubtractMonths(12))); _logger.Trace(() => existsResponse.GetRequest()); Assert.True(existsResponse.IsValid); Assert.False(existsResponse.Exists); } }
public async Task MaintainOnlyOldIndexesWithNoExistingAliasesAsync() { using (TestSystemClock.Install()) { TestSystemClock.SetFrozenTime(SystemClock.UtcNow.EndOfYear()); var index = new MonthlyEmployeeIndex(_configuration, 1) { MaxIndexAge = SystemClock.UtcNow.EndOfMonth() - SystemClock.UtcNow.SubtractMonths(12).StartOfMonth() }; await index.EnsureIndexAsync(SystemClock.UtcNow.SubtractMonths(12)); var existsResponse = await _client.Indices.ExistsAsync(index.GetIndex(SystemClock.UtcNow.SubtractMonths(12))); _logger.LogRequest(existsResponse); Assert.True(existsResponse.ApiCall.Success); Assert.True(existsResponse.Exists); index.MaxIndexAge = SystemClock.UtcNow.EndOfMonth() - SystemClock.UtcNow.StartOfMonth(); await DeleteAliasesAsync(index.GetVersionedIndex(SystemClock.UtcNow.SubtractMonths(12))); await index.MaintainAsync(); existsResponse = await _client.Indices.ExistsAsync(index.GetIndex(SystemClock.UtcNow.SubtractMonths(12))); _logger.LogRequest(existsResponse); Assert.True(existsResponse.ApiCall.Success); Assert.False(existsResponse.Exists); } }