List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudAppDashElement restart
@Override public void restart(RunState runningOrDebugging, UserInteractions ui) throws Exception
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void stopCancelsStart() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator")); final String appName = "foo"; space.defApp(appName);//from w w w . j av a2s . co m CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName); CloudAppDashElement app = model.getApplication(appName); app.setProject(project); waitForApps(model, appName); clientFactory.setAppStartDelay(TimeUnit.MINUTES, 2); app.getBaseRunStateExp().addListener(new ValueListener<RunState>() { @Override public void gotValue(LiveExpression<RunState> exp, RunState value) { System.out.println("Runstate -> " + value); } }); System.out.println("Restaring app..."); app.restart(RunState.RUNNING, ui); waitForState(app, RunState.STARTING, 30000); System.out.println("Stopping app..."); app.stopAsync(ui); waitForState(app, RunState.INACTIVE, 20000); System.out.println("Stopped!"); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void manifestDiffDialogNotShownWhenNothingChanged() throws Exception { final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator")); createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n"); MockCFApplication deployedApp = space.defApp(appName); deployedApp.start(CancelationTokens.NULL); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName);/*from w w w . j a v a 2s . c o m*/ CloudAppDashElement app = model.getApplication(appName); app.setDeploymentManifestFile(project.getFile("manifest.yml")); app.setProject(project); assertEquals(1, app.getActualInstances()); // deployedApp.scaleInstances(2); // change it 'externally' assertEquals(1, app.getActualInstances()); //The model doesn't know yet that it has changed! // harness.answerDeploymentPrompt(ui, appName, appName); app.restart(RunState.RUNNING, ui); waitForJobsToComplete(); //If no change was detected the manfiest compare dialog shouldn't have popped. verify(ui, never()).openManifestDiffDialog(any()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void manifestDiffDialogShownWhenInstancesChangedExternally() throws Exception { final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator")); createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n"); MockCFApplication deployedApp = space.defApp(appName); deployedApp.start(CancelationTokens.NULL); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName);/*from ww w . ja va 2s . co m*/ waitForJobsToComplete(); CloudAppDashElement app = model.getApplication(appName); app.setDeploymentManifestFile(project.getFile("manifest.yml")); app.setProject(project); assertEquals(1, app.getActualInstances()); deployedApp.scaleInstances(2); // change it 'externally' assertEquals(1, app.getActualInstances()); //The model doesn't know yet that it has changed! app.restart(RunState.RUNNING, ui); waitForJobsToComplete(); //If the change was detected the deployment props dialog should have popped exactly once. verify(ui).openManifestDiffDialog(any()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void manifestDiffDialogChooseUseManfifest() throws Exception { //Setup initial state for our test final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator")); IFile manifest = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " memory: 1111M\n"); harness.answerDeploymentPrompt(ui, manifest); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);/*from ww w .j a v a2s.c om*/ CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, APP_DEPLOY_TIMEOUT); { MockCFApplication appInCloud = space.getApplication(appName); assertEquals(1111, appInCloud.getMemory()); Mockito.reset(ui); //// real test begins here appInCloud.setMemory(2222); } harness.answerManifestDiffDialog(ui, (ManifestDiffDialogModel dialog) -> { //??? code to check what's in the dialog??? return ManifestDiffDialogModel.Result.USE_MANIFEST; }); app.restart(RunState.RUNNING, ui); waitForJobsToComplete(); { MockCFApplication appInCloud = space.getApplication(appName); assertEquals(2, appInCloud.getPushCount()); assertEquals(RunState.RUNNING, app.getRunState()); assertEquals(1111, appInCloud.getMemory()); assertEquals(1111, (int) app.getMemory()); } }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void manifestDiffDialogChooseForgetManfifest() throws Exception { //Setup initial state for our test final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator")); IFile manifest = createFile(project, "manifest.yml", "applications:\n" + "- name: " + appName + "\n" + " memory: 1111M\n"); harness.answerDeploymentPrompt(ui, manifest); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, appName);/*from w ww.ja v a 2 s .com*/ CloudAppDashElement app = model.getApplication(appName); waitForState(app, RunState.RUNNING, APP_DEPLOY_TIMEOUT); MockCFApplication appInCloud = space.getApplication(appName); assertEquals(1111, appInCloud.getMemory()); Mockito.reset(ui); //// real test begins here appInCloud.setMemory(2222); harness.answerManifestDiffDialog(ui, (ManifestDiffDialogModel dialog) -> { //??? code to check what's in the dialog??? return ManifestDiffDialogModel.Result.FORGET_MANIFEST; }); app.restart(RunState.RUNNING, ui); waitForJobsToComplete(); assertEquals(2, appInCloud.getPushCount()); assertEquals(RunState.RUNNING, app.getRunState()); assertEquals(2222, appInCloud.getMemory()); assertEquals(2222, (int) app.getMemory()); }