use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.
the class OpenShiftServiceRequirement method cleanUp.
@Override
public void cleanUp() {
if (serviceSpec.cleanup()) {
String projectName = TestUtils.getValueOrDefault(serviceSpec.project(), DatastoreOS3.TEST_PROJECT);
final IProject project = OpenShift3NativeResourceUtils.getProject(projectName, connection);
IProjectTemplateProcessing capability = project.getCapability(IProjectTemplateProcessing.class);
ITemplate processed = capability.process(template);
for (IResource resource : processed.getObjects()) {
IResource res = connection.getResource(resource.getKind(), projectName, resource.getName());
try {
connection.deleteResource(res);
} catch (OpenShiftException ex) {
LOGGER.error("Unable to remove " + res.getKind() + " named " + res.getName());
LOGGER.error(StackTraceUtils.stackTraceToString(ex));
}
}
cleanResources(connection, ResourceKind.BUILD, project, template);
cleanResources(connection, ResourceKind.REPLICATION_CONTROLLER, project, template);
cleanResources(connection, ResourceKind.POD, project, template);
new WaitWhile(new AbstractWaitCondition() {
@Override
public boolean test() {
for (IResource resource : project.getResources(ResourceKind.POD)) {
if (resource.getName().startsWith(template.getName())) {
return true;
}
}
return false;
}
@Override
public String description() {
return "at least one application pod is running";
}
}, TimePeriod.LONG);
new OpenShiftExplorerView().getOpenShift3Connection(connection).refresh();
}
}
use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.
the class DebuggingEAPAppTest method checkNewVariableValueIsPropagatedToBrowser.
private void checkNewVariableValueIsPropagatedToBrowser() {
clickResume();
new WaitUntil(new AbstractWaitCondition() {
@Override
public boolean test() {
return ((requestResponse != null) && requestResponse.contains("NewWorld"));
}
}, TimePeriod.LONG);
}
use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.
the class DebuggingEAPAppTest method checkVariablesView.
private void checkVariablesView() {
VariablesView variablesView = new VariablesView();
variablesView.open();
// wait for variables to have correct value
new WaitUntil(new AbstractWaitCondition() {
@Override
public boolean test() {
return variablesView.getValue("name").equals("World");
}
});
new WaitUntil(new AbstractWaitCondition() {
@Override
public boolean test() {
return variablesView.getValue("this").contains("HelloService");
}
});
}
use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.
the class OpenShiftServiceRequirement method waitForUI.
/**
* Waits for the service and replication controller to appear in the UI,
* possibly refreshes the project. This shouldnt be required but turns out
* that the UI takes extensive amount of time to notice the new resources.
* We therefore make sure they are present in UI before considering this
* requirement as fullfilled and possibly refresh the project (in ui) to
* force it to appear. This shouldnt be necessary, I consider this as workaround.
*
* @param projectName
* @param serviceName
*/
private void waitForUI(final String serviceName, final String projectName) {
// wait for service to appear in UI
new WaitUntil(new AbstractWaitCondition() {
@Override
public boolean test() {
OpenShiftExplorerView explorer = new OpenShiftExplorerView();
explorer.open();
OpenShift3Connection os3Connection = explorer.getOpenShift3Connection(connection);
assertThat(os3Connection, not(nullValue()));
OpenShiftProject os3Project = os3Connection.getProject(projectName);
assertThat(os3Project, not(nullValue()));
boolean serviceExists = false;
try {
serviceExists = os3Project.getService(serviceName) != null;
} catch (RedDeerException e) {
// catched intentionnally
System.err.println(e);
}
/*
* WORKAROUND: UI takes extensive amount of time to notice resource changes
* -> refresh tree to force it to see changes
*/
if (!serviceExists) {
os3Project.refresh();
}
return serviceExists;
}
}, TimePeriod.VERY_LONG);
// wait for replication controller to appear in UI
List<IReplicationController> rcs = connection.getResources(ResourceKind.REPLICATION_CONTROLLER, service.getNamespaceName());
IReplicationController serviceRc = ResourceUtils.getReplicationControllerFor(service, rcs);
assertThat(serviceRc, not(nullValue()));
new WaitUntil(new OpenShiftResourceExists(Resource.DEPLOYMENT, containsString(serviceRc.getName()), ResourceState.UNSPECIFIED, projectName, connection), TimePeriod.VERY_LONG);
}
use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.
the class DebuggingEAPAppTest method ensureCorrectFrameIsSelected.
private TreeItem ensureCorrectFrameIsSelected(LaunchView debugView) {
List<TreeItem> items;
TreeItem createHelloMessageDebugItem;
// get frames of suspended thread. If the desired frame is not present,
// try reopening Debug view
items = getSuspendedThreadTreeItem(debugView).getItems();
if (items.size() < 2) {
// no stack trace available. Try to close&reopen Debug view (dirty
// hack)
debugView.close();
debugView = new LaunchView();
debugView.open();
items = getSuspendedThreadTreeItem(debugView).getItems();
}
final List<TreeItem> tIList = items;
// wait for frame texts to populate.
new WaitUntil(new AbstractWaitCondition() {
@Override
public boolean test() {
return tIList.stream().peek(ti -> LOGGER.debug(ti.getText())).filter(ti -> ti.getText().contains("createHelloMessage")).findFirst().isPresent();
}
}, TimePeriod.LONG);
createHelloMessageDebugItem = tIList.stream().peek(ti -> LOGGER.debug(ti.getText())).filter(ti -> ti.getText().contains("createHelloMessage")).findFirst().get();
// select the item and return it
createHelloMessageDebugItem.select();
return createHelloMessageDebugItem;
}
Aggregations