Skip to content

Commit

Permalink
Small enhancements to AdmiralUpgradeBaseIT
Browse files Browse the repository at this point in the history
Added error messages for assertions, changed some assert methods to more
explicit ones.

Change-Id: I0ae793aa4c19f79a5c0c33d046964348234cdfe8
Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/44102
Upgrade-Verified: jenkins <[email protected]>
Closures-Verified: jenkins <[email protected]>
PG-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Reviewed-by: Georgi Muleshkov <[email protected]>
  • Loading branch information
shadjiiski committed Sep 14, 2018
1 parent be1673a commit 687f136
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

package com.vmware.admiral.test.integration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

Expand Down Expand Up @@ -134,7 +135,8 @@ protected void validateContent(ContainerState admiralContainer) throws Exception
com.vmware.admiral.test.integration.client.ComputeState dockerHost = getDocument(
COMPUTE_SELF_LINK,
com.vmware.admiral.test.integration.client.ComputeState.class);
assertTrue(dockerHost != null);
assertNotNull("Expected a compute state with selflink " + COMPUTE_SELF_LINK + " to exist",
dockerHost);
// Run the data collection in order to update the host
ContainerHostDataCollectionState dataCollectionBody = new ContainerHostDataCollectionState();
sendRequest(HttpMethod.PATCH,
Expand All @@ -155,7 +157,8 @@ protected void validateContent(ContainerState admiralContainer) throws Exception
com.vmware.admiral.test.integration.client.AuthCredentialsServiceState credentials = getDocument(
CREDENTIALS_SELF_LINK,
com.vmware.admiral.test.integration.client.AuthCredentialsServiceState.class);
assertNotNull(credentials);
assertNotNull("Expected credentials with selflink " + CREDENTIALS_SELF_LINK + " to exist",
credentials);

// container
logger.info("--- Validate containers. ---");
Expand Down Expand Up @@ -291,13 +294,15 @@ private <T> void validateResources(String endpoint, Class<? extends T> clazz)
URI uri = URI.create(getBaseUrl() + endpoint);
waitForStatusCode(uri, Operation.STATUS_CODE_OK);

HttpResponse response = SimpleHttpsClient.execute(HttpMethod.GET,
getBaseUrl() + buildServiceUri(endpoint + EXPAND), null, null);
assertTrue(response.statusCode == 200);
String targetUrl = getBaseUrl() + buildServiceUri(endpoint + EXPAND);
HttpResponse response = SimpleHttpsClient.execute(HttpMethod.GET, targetUrl, null, null);
assertEquals("Unexpected status code when trying to get " + targetUrl,
Operation.STATUS_CODE_OK, response.statusCode);
JsonElement json = new JsonParser().parse(response.responseBody);
JsonObject jsonObject = json.getAsJsonObject();
JsonArray documentLinks = jsonObject.getAsJsonArray(DOCUMENT_LINKS);
assertTrue(documentLinks.size() > 0);
assertTrue("No documentLinks found in response of GET " + targetUrl,
documentLinks.size() > 0);
for (int i = 0; i < documentLinks.size(); i++) {
String selfLink = documentLinks.get(i).getAsString();
T state = getDocument(selfLink, clazz);
Expand Down

0 comments on commit 687f136

Please sign in to comment.