[TEST] Waiting longer for native realm migration
Let LicensingTests.testNativeRealmMigratorWorksUnderBasicLicense wait for 3s (instead of 1s) as it is occasionally failing. Also added logging so that if/when it does fail we can see how long we were waiting and what was taking place. Original commit: elastic/x-pack-elasticsearch@22882ec412
This commit is contained in:
parent
672819f038
commit
9f6285f362
|
@ -270,7 +270,9 @@ public class LicensingTests extends SecurityIntegTestCase {
|
||||||
public void testNativeRealmMigratorWorksUnderBasicLicense() throws Exception {
|
public void testNativeRealmMigratorWorksUnderBasicLicense() throws Exception {
|
||||||
final String securityIndex = ".security";
|
final String securityIndex = ".security";
|
||||||
final String reservedUserType = "reserved-user";
|
final String reservedUserType = "reserved-user";
|
||||||
|
final String securityVersionField = "security-version";
|
||||||
final String oldVersionThatRequiresMigration = Version.V_5_0_2.toString();
|
final String oldVersionThatRequiresMigration = Version.V_5_0_2.toString();
|
||||||
|
final String expectedVersionAfterMigration = Version.CURRENT.toString();
|
||||||
|
|
||||||
final Client client = internalCluster().transportClient();
|
final Client client = internalCluster().transportClient();
|
||||||
final String template = TemplateUtils.loadTemplate("/" + SecurityTemplateService.SECURITY_TEMPLATE_NAME + ".json",
|
final String template = TemplateUtils.loadTemplate("/" + SecurityTemplateService.SECURITY_TEMPLATE_NAME + ".json",
|
||||||
|
@ -298,18 +300,21 @@ public class LicensingTests extends SecurityIntegTestCase {
|
||||||
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
|
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
|
||||||
|
|
||||||
final GetMappingsRequest getMappingsRequest = client.admin().indices().prepareGetMappings(securityIndex).request();
|
final GetMappingsRequest getMappingsRequest = client.admin().indices().prepareGetMappings(securityIndex).request();
|
||||||
|
logger.info("Waiting for '{}' in mapping meta-data of index '{}' to equal '{}'",
|
||||||
|
securityVersionField, securityIndex, expectedVersionAfterMigration);
|
||||||
final boolean upgradeOk = awaitBusy(() -> {
|
final boolean upgradeOk = awaitBusy(() -> {
|
||||||
final GetMappingsResponse getMappingsResponse = client.admin().indices().getMappings(getMappingsRequest).actionGet();
|
final GetMappingsResponse getMappingsResponse = client.admin().indices().getMappings(getMappingsRequest).actionGet();
|
||||||
final MappingMetaData metaData = getMappingsResponse.mappings().get(securityIndex).get(reservedUserType);
|
final MappingMetaData metaData = getMappingsResponse.mappings().get(securityIndex).get(reservedUserType);
|
||||||
try {
|
try {
|
||||||
Map<String, Object> meta = (Map<String, Object>) metaData.sourceAsMap().get("_meta");
|
Map<String, Object> meta = (Map<String, Object>) metaData.sourceAsMap().get("_meta");
|
||||||
return meta != null && Version.CURRENT.toString().equals(meta.get("security-version"));
|
return meta != null && expectedVersionAfterMigration.equals(meta.get(securityVersionField));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, 1, TimeUnit.SECONDS);
|
}, 3, TimeUnit.SECONDS);
|
||||||
assertThat(upgradeOk, equalTo(true));
|
assertThat("Update of " + securityVersionField + " did not happen within allowed time limit", upgradeOk, equalTo(true));
|
||||||
|
|
||||||
|
logger.info("Update of {}/{} complete, checking that logstash_system user exists", securityIndex, securityVersionField);
|
||||||
final GetRequest getRequest = client.prepareGet(securityIndex, reservedUserType, "logstash_system").setRefresh(true).request();
|
final GetRequest getRequest = client.prepareGet(securityIndex, reservedUserType, "logstash_system").setRefresh(true).request();
|
||||||
final GetResponse getResponse = client.get(getRequest).actionGet();
|
final GetResponse getResponse = client.get(getRequest).actionGet();
|
||||||
assertThat(getResponse.isExists(), equalTo(true));
|
assertThat(getResponse.isExists(), equalTo(true));
|
||||||
|
|
Loading…
Reference in New Issue