Skip to content

Commit

Permalink
Fix config props init inside ContainerHostEventsIT
Browse files Browse the repository at this point in the history
- when we create a document with postDocument method, at the end
of the test this document gets deleted.

Change-Id: I2ce714079bf92c5e686442a6f15162149fa1e335
Reviewed-on: http://bellevue-ci.eng.vmware.com:8080/23332
Upgrade-Verified: jenkins <[email protected]>
Closures-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Reviewed-by: Miroslav Shipkovenski <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
  • Loading branch information
afilipov1 committed Dec 15, 2017
1 parent c5e8846 commit 34257df
Showing 1 changed file with 33 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,46 +51,39 @@ public class ContainerHostEventsIT extends BaseProvisioningOnCoreOsIT {
@BeforeClass
public static void beforeClass() throws Throwable {
serviceClient = ServiceClientFactory.createServiceClient(null);

// enable host events subscription
ConfigurationService.ConfigurationState config = new ConfigurationService.ConfigurationState();
config.key = ConfigurationUtil.ALLOW_HOST_EVENTS_SUBSCRIPTIONS;
config.value = "true";
config.documentSelfLink = config.key;

postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, config);
}

@AfterClass
public static void afterClass() throws Exception {
serviceClient = ServiceClientFactory.createServiceClient(null);
}

// disable host events subscription
@Before
public void setUp() throws Exception {
DeploymentProfileConfig.getInstance().setTest(true);

// enable host events subscription
ConfigurationService.ConfigurationState config = new ConfigurationService.ConfigurationState();
config.key = ConfigurationUtil.ALLOW_HOST_EVENTS_SUBSCRIPTIONS;
config.value = "false";
config.value = Boolean.TRUE.toString();
config.documentSelfLink = config.key;

postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, config);
}
config = postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, config);
assertEquals(Boolean.TRUE.toString(), config.value);

@Before
public void setUp() throws Exception {
DeploymentProfileConfig.getInstance().setTest(true);
// set throw IO exception in order to simulate this kind of exception
ConfigurationService.ConfigurationState configState = new ConfigurationService.ConfigurationState();
configState.key = ConfigurationUtil.THROW_IO_EXCEPTION;
configState.value = Boolean.TRUE.toString();
configState.documentSelfLink = configState.key;
configState = postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, configState);
assertEquals(Boolean.TRUE.toString(), configState.value);
}

@After
public void cleanUp() throws Exception {
DeploymentProfileConfig.getInstance().setTest(false);

// disable the simulation of the IOException
ConfigurationService.ConfigurationState config = new ConfigurationService.ConfigurationState();
config.key = ConfigurationUtil.THROW_IO_EXCEPTION;
config.value = "false";
config.documentSelfLink = config.key;
ConfigurationService.ConfigurationState configState = postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, config);
assertEquals(Boolean.FALSE.toString(), configState.value);

final long timoutInMillis = 20000; // 20sec
long startTime = System.currentTimeMillis();

Expand All @@ -102,6 +95,23 @@ public void cleanUp() throws Exception {
TimeUnit.MILLISECONDS.toSeconds(timoutInMillis - (System.currentTimeMillis() - startTime)));
return System.currentTimeMillis() - startTime > timoutInMillis;
});

// disable host events subscription
ConfigurationService.ConfigurationState config = new ConfigurationService.ConfigurationState();
config.key = ConfigurationUtil.ALLOW_HOST_EVENTS_SUBSCRIPTIONS;
config.value = Boolean.FALSE.toString();
config.documentSelfLink = config.key;

config = postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, config);
assertEquals(Boolean.FALSE.toString(), config.value);

// disable the simulation of the IOException
ConfigurationService.ConfigurationState configState = new ConfigurationService.ConfigurationState();
configState.key = ConfigurationUtil.THROW_IO_EXCEPTION;
configState.value = Boolean.FALSE.toString();
configState.documentSelfLink = configState.key;
configState = postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, configState);
assertEquals(Boolean.FALSE.toString(), configState.value);
}

@Override
Expand Down Expand Up @@ -152,13 +162,6 @@ public void testContainerDies() throws Exception {
public void testHostDies() throws Exception {
compositeDescriptionLink = importTemplate(serviceClient, TEMPLATE_FILE);

// set throw IO exception in order to simulate this kind of exception
ConfigurationService.ConfigurationState config = new ConfigurationService.ConfigurationState();
config.key = ConfigurationUtil.THROW_IO_EXCEPTION;
config.value = "true";
config.documentSelfLink = config.key;
postDocument(ConfigurationService.ConfigurationFactoryService.SELF_LINK, config);

setupCoreOsHost(ContainerHostService.DockerAdapterType.API, false);

ComputeState cs = getDockerHost();
Expand Down

0 comments on commit 34257df

Please sign in to comment.