List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudFoundryBootDashModel performDeployment
public void performDeployment(final Set<IProject> projectsToDeploy, final UserInteractions ui, RunState runOrDebug) throws Exception
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testDeployAppIntoDebugMode() throws Exception { harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); final BootProjectDashElement project = harness .getElementFor(projects.createBootProject("to-deploy", withStarters("actuator", "web"))); final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName); model.performDeployment(ImmutableSet.of(project.getProject()), ui, RunState.DEBUGGING); new ACondition("wait for app '" + appName + "'to be DEBUGGING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.DEBUGGING, element.getRunState()); return true; }/*from w w w. ja va 2 s. c o m*/ }; }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testEnvVarsSetOnFirstDeploy() throws Exception { CloudFoundryBootDashModel target = harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); Map<String, String> env = new HashMap<>(); env.put("FOO", "something"); harness.answerDeploymentPrompt(ui, appName, appName, env); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); new ACondition("wait for app '" + appName + "'to be RUNNING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; }//ww w . j ava2s.c o m }; Map<String, String> actualEnv = harness.fetchEnvironment(target, appName); assertEquals("something", actualEnv.get("FOO")); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testServicesBoundOnFirstDeploy() throws Exception { CloudFoundryBootDashModel target = harness.createCfTarget(CfTestTargetParams.fromEnv()); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); List<String> bindServices = ImmutableList.of(services.createTestService(), services.createTestService()); ACondition.waitFor("services exist " + bindServices, 30_000, () -> { Set<String> services = client.getServices().stream().map(CFServiceInstance::getName) .collect(Collectors.toSet()); System.out.println("services = " + services); assertTrue(services.containsAll(bindServices)); });/*from w ww . j a va 2s.c o m*/ final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName, bindServices); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); new ACondition("wait for app '" + appName + "'to be RUNNING", APP_DEPLOY_TIMEOUT) { public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; } }; Set<String> actualServices = client.getBoundServicesSet(appName).block(); assertEquals(ImmutableSet.copyOf(bindServices), actualServices); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelIntegrationTest.java
@Test public void testDeployManifestWithAbsolutePathAttribute() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); IProject project = projects.createProject("to-deploy"); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForJobsToComplete();/*from w w w. j a va2s . c o m*/ File zipFile = getTestZip("testapp"); final String appName = appHarness.randomAppName(); IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " path: " + zipFile.getAbsolutePath() + "\n" + " buildpack: staticfile_buildpack"); harness.answerDeploymentPrompt(ui, manifestFile); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); ACondition.waitFor("app to appear", APP_IS_VISIBLE_TIMEOUT, () -> { assertNotNull(model.getApplication(appName)); }); CloudAppDashElement app = model.getApplication(appName); ACondition.waitFor("app to be running", APP_DEPLOY_TIMEOUT, () -> { assertEquals(RunState.RUNNING, app.getRunState()); String url = pathJoin(app.getUrl(), "test.txt"); assertEquals(url, "some content here\n", IOUtils.toString(new URL(url))); }); verify(ui).promptApplicationDeploymentProperties(any()); verifyNoMoreInteractions(ui); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testEnvVarsSetOnFirstDeploy() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel target = harness.createCfTarget(targetParams); final CloudFoundryBootDashModel model = harness.getCfTargetModel(); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); Map<String, String> env = new HashMap<>(); env.put("FOO", "something"); harness.answerDeploymentPrompt(ui, appName, appName, env); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); new ACondition("wait for app '" + appName + "'to be RUNNING", 30000) { //why so long? JDT searching for main type. public boolean test() throws Exception { CloudAppDashElement element = model.getApplication(appName); assertEquals(RunState.RUNNING, element.getRunState()); return true; }/*from ww w .j a v a 2s . c om*/ }; Map<String, String> actualEnv = harness.fetchEnvironment(target, appName); assertEquals("something", actualEnv.get("FOO")); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void simpleDeploy() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); harness.answerDeploymentPrompt(ui, appName, appName); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);//from w w w .j ava 2 s. com CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, 10000); assertEquals((Integer) 1, space.getPushCount(appName).getValue()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void simpleDeployWithManifest() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " memory: 512M\n"); harness.answerDeploymentPrompt(ui, (dialog) -> { dialog.okPressed();// w w w . j a va2 s . c o m }); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName); CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, 10000); assertEquals((Integer) 1, space.getPushCount(appName).getValue()); assertEquals(manifestFile, app.getDeploymentManifestFile()); assertEquals(512, (int) app.getMemory()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void simpleDeployWithDefaultManualManifest() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = project.getName(); harness.answerDeploymentPrompt(ui, (dialog) -> { dialog.okPressed();/*www . j a v a 2s . c om*/ }); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName); CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, 10000); assertEquals((Integer) 1, space.getPushCount(appName).getValue()); assertNull(app.getDeploymentManifestFile()); assertEquals(1024, (int) app.getMemory()); assertEquals(appName, app.getName()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void stopCancelsDeploy() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = appHarness.randomAppName(); clientFactory.setAppStartDelay(TimeUnit.MINUTES, 2); harness.answerDeploymentPrompt(ui, appName, appName); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);/*from w w w . j a v a 2s. co m*/ CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.STARTING, 3000); ACondition.waitFor("stop hammering", 20000, () -> { app.stopAsync(ui); assertEquals(RunState.INACTIVE, app.getRunState()); }); //TODO: can we check that deployment related jobs are really canceled/finished somehow? // can we check that they didn't pop errors? }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void acceptDeployOfExistingApp() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = "foo"; MockCFApplication deployedApp = space.defApp(appName); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName);/*from w ww . j a v a 2 s . c o m*/ CloudAppDashElement app = model.getApplication(appName); app.setProject(null); assertNull(app.getProject()); assertEquals(RunState.INACTIVE, app.getRunState()); harness.answerDeploymentPrompt(ui, appName, appName); Mockito.doReturn(true).when(ui).confirmOperation(same("Replace Existing Application"), any()); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); System.out.println(app.getRunState()); waitForJobsToComplete(); System.out.println(app.getRunState()); assertEquals(project, app.getProject()); assertEquals(1, deployedApp.getPushCount()); verify(ui).confirmOperation(any(), any()); }