List of usage examples for org.springframework.ide.eclipse.boot.util RetryUtil retryTimes
public static void retryTimes(String name, int tries, Thunk task) throws Exception
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryClientTest.java
@Test public void testPushAndBindServices() throws Exception { //This test fails occasionally because service binding is 'unreliable'. Had a long discussion // with Ben Hale. The gist is errors happen and should be expected in distributed world. //They are coming from 'AppDirect' which manages the services. The errors are mediated through cloudfoundry // which doesn't knwow how it should handle them. So it passed the buck onto the its callers. //In this case.... cf-java-client which does the same thing and passes them to us. //All the reasons why they can't handle these errors also apply to us, which means that //the operation is simply unreliable and so failure is an expected outcome even when everything //works correctly. //To avoid this test case from failing too often we retry it a few times. RetryUtil.retryTimes("testPushAndBindServices", 4, () -> { System.out.println("Executing full test scenario."); String service1 = services.createTestService(); String service2 = services.createTestService(); String service3 = services.createTestService(); //An extra unused service (makes this a better test). String appName = appHarness.randomAppName(); CFPushArguments params = new CFPushArguments(); params.setAppName(appName);// ww w . j a v a 2s . co m params.setApplicationData(getTestZip("testapp")); params.setBuildpack("staticfile_buildpack"); params.setServices(ImmutableList.of(service1, service2)); push(params); assertEquals(ImmutableSet.of(service1, service2), getBoundServiceNames(appName)); client.bindAndUnbindServices(appName, ImmutableList.of(service1)).block(); assertEquals(ImmutableSet.of(service1), getBoundServiceNames(appName)); client.bindAndUnbindServices(appName, ImmutableList.of(service2)).block(); assertEquals(ImmutableSet.of(service2), getBoundServiceNames(appName)); client.bindAndUnbindServices(appName, ImmutableList.of()).block(); assertEquals(ImmutableSet.of(), getBoundServiceNames(appName)); }); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryServicesHarness.java
protected void deleteOwnedServices() { if (!ownedServiceNames.isEmpty()) { System.out.println("owned services: " + ownedServiceNames); try {/*from w w w . java 2s .c o m*/ for (String serviceName : ownedServiceNames) { System.out.println("delete service: " + serviceName); try { RetryUtil.retryTimes("delete sercice " + serviceName, 3, () -> { this.client.deleteServiceAsync(serviceName).block(DELETE_SERVICE_TIMEOUT); }); } catch (Exception e) { System.out .println("Failed to delete [" + serviceName + "]: " + ExceptionUtil.getMessage(e)); // May get 404 or other 400 errors if it is alrready // gone so don't prevent other owned apps from being // deleted } } } catch (Exception e) { fail("failed to cleanup owned services: " + e.getMessage()); } } }