com.google.cloud.tools.appengine.operations.cloudsdk.process.ProcessHandlerException Java Examples
The following examples show how to use
com.google.cloud.tools.appengine.operations.cloudsdk.process.ProcessHandlerException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeployMojoIntegrationTest.java From app-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeployFlexible() throws IOException, VerificationException, CloudSdkNotFoundException, ProcessHandlerException { Verifier verifier = new FlexibleVerifier("testDeployFlexible"); // execute with staging directory not present verifier.executeGoal("package"); verifier.executeGoal("appengine:deploy"); // verify verifier.verifyErrorFreeLog(); verifier.verifyTextInLog("Detected App Engine flexible environment application"); verifier.verifyTextInLog("GCLOUD: Deployed service"); // verify debugger required file generation verifier.assertFilePresent( "target/flexible-project-1.0-SNAPSHOT/WEB-INF/classes/" + "source-context.json"); // cleanup deleteService("flexible-project"); }
Example #2
Source File: GenRepoInfoFileTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testGenerate() throws AppEngineException, ProcessHandlerException, IOException { GcloudRunner gcloudRunner = Mockito.mock(GcloudRunner.class); GenRepoInfoFile model = new GenRepoInfoFile(gcloudRunner); GenRepoInfoFileConfiguration configuration = GenRepoInfoFileConfiguration.builder() .outputDirectory(Paths.get("output")) .sourceDirectory(Paths.get("source")) .build(); model.generate(configuration); List<String> arguments = ImmutableList.of( "beta", "debug", "source", "gen-repo-info-file", "--output-directory", Paths.get("output").toAbsolutePath().toString(), "--source-directory", Paths.get("source").toAbsolutePath().toString()); Mockito.verify(gcloudRunner).run(arguments, null); }
Example #3
Source File: AppEngineAppYamlPluginIntegrationTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeploy() throws CloudSdkNotFoundException, IOException, ProcessHandlerException, UnsupportedOsException { BuildResult buildResult = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withPluginClasspath() .withArguments("appengineDeploy") .build(); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Deployed service [appyaml-project]")); deleteProject(); }
Example #4
Source File: DevServerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testPrepareCommand_noFlagsMultiModule() throws AppEngineException, ProcessHandlerException, IOException { RunConfiguration configuration = RunConfiguration.builder(ImmutableList.of(java7Service, java8Service)).build(); List<String> expectedFlags = ImmutableList.of( "--allow_remote_shutdown", "--disable_update_check", "--no_java_agent", java7Service.toString(), java8Service.toString()); List<String> expectedJvmArgs = ImmutableList.of("-Duse_jetty9_runtime=true", "-D--enable_all_permissions=true"); devServer.run(configuration); verify(devAppServerRunner, times(1)) .run(expectedJvmArgs, expectedFlags, expectedJava8Environment, null /* workingDirectory */); }
Example #5
Source File: DevServerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testPrepareCommand_noFlagsJava7() throws AppEngineException, ProcessHandlerException, IOException { RunConfiguration configuration = RunConfiguration.builder(ImmutableList.of(java7Service)).build(); List<String> expectedFlags = ImmutableList.of( "--allow_remote_shutdown", "--disable_update_check", java7Service.toString()); List<String> expectedJvmArgs = ImmutableList.of( "-javaagent:" + fakeJavaSdkHome.resolve("agent/appengine-agent.jar").toAbsolutePath().toString()); devServer.run(configuration); verify(devAppServerRunner, times(1)) .run( expectedJvmArgs, expectedFlags, expectedJava7Environment, java7Service /* workingDirectory */); }
Example #6
Source File: DevServerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testPrepareCommand_noFlags() throws AppEngineException, ProcessHandlerException, IOException { RunConfiguration configuration = RunConfiguration.builder(ImmutableList.of(java8Service)).build(); List<String> expectedFlags = ImmutableList.of( "--allow_remote_shutdown", "--disable_update_check", "--no_java_agent", java8Service.toString()); List<String> expectedJvmArgs = ImmutableList.of("-Duse_jetty9_runtime=true", "-D--enable_all_permissions=true"); devServer.run(configuration); verify(devAppServerRunner, times(1)) .run( expectedJvmArgs, expectedFlags, expectedJava8Environment, java8Service /* workingDirectory */); }
Example #7
Source File: DevServerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testPrepareCommand_booleanFlags() throws AppEngineException, ProcessHandlerException, IOException { RunConfiguration configuration = RunConfiguration.builder(ImmutableList.of(java8Service)).build(); List<String> expectedFlags = ImmutableList.of( "--allow_remote_shutdown", "--disable_update_check", "--no_java_agent", java8Service.toString()); List<String> expectedJvmArgs = ImmutableList.of("-Duse_jetty9_runtime=true", "-D--enable_all_permissions=true"); devServer.run(configuration); verify(devAppServerRunner, times(1)) .run( expectedJvmArgs, expectedFlags, expectedJava8Environment, java8Service /* workingDirectory */); }
Example #8
Source File: WaitingProcessOutputLineListener.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** * Blocks the executing thread until the specified message is seen through {@link * #onOutputLine(String)}. If the message is not seen within the specified timeout, {@link * ProcessHandlerException} will be thrown. */ public void await() throws ProcessHandlerException { try { if (message != null && timeoutSeconds != 0 && !waitLatch.await(timeoutSeconds, TimeUnit.SECONDS)) { throw new ProcessHandlerException( "Timed out waiting for the success message: '" + message + "'"); } if (exited) { throw new ProcessHandlerException("Process exited before success message"); } } catch (InterruptedException e) { throw new ProcessHandlerException(e); } finally { waitLatch.countDown(); } }
Example #9
Source File: AppEngineWebXmlProjectStagingTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Before public void setUp() throws IOException, InvalidJavaSdkException, ProcessHandlerException, AppEngineJavaComponentsNotInstalledException { source = tmpDir.newFolder("source").toPath(); destination = tmpDir.newFolder("destination").toPath(); dockerfile = tmpDir.newFile("dockerfile").toPath(); staging = new AppEngineWebXmlProjectStaging(appCfgRunner); builder = AppEngineWebXmlProjectStageConfiguration.builder() .sourceDirectory(source) .stagingDirectory(destination); // create an app.yaml in staging output when we run. Mockito.doAnswer( ignored -> { Files.createFile(destination.resolve("app.yaml")); return null; }) .when(appCfgRunner) .run(Mockito.anyList()); }
Example #10
Source File: GenRepoInfoFile.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** * Generates source context files. * * <p>It is possible for the process to return an error code. In that case, no exception is * thrown, but the code must be caught with a {@link * com.google.cloud.tools.appengine.operations.cloudsdk.process.ProcessExitListener} attached to * the {@link CloudSdk} object used to run the command. * * @param configuration contains the source and output directories * @throws AppEngineException when there is an issue running the gcloud process */ public void generate(GenRepoInfoFileConfiguration configuration) throws AppEngineException { List<String> arguments = new ArrayList<>(); arguments.add("beta"); arguments.add("debug"); arguments.add("source"); arguments.add("gen-repo-info-file"); arguments.addAll(GcloudArgs.get("output-directory", configuration.getOutputDirectory())); arguments.addAll(GcloudArgs.get("source-directory", configuration.getSourceDirectory())); try { runner.run(arguments, null); } catch (ProcessHandlerException | IOException ex) { throw new AppEngineException(ex); } }
Example #11
Source File: AppEngineWebXmlProjectStagingTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testCheckFlags_booleanFlags() throws AppEngineException, ProcessHandlerException, IOException { builder.enableQuickstart(false); builder.disableUpdateCheck(false); builder.enableJarSplitting(false); builder.deleteJsps(false); builder.enableJarClasses(false); builder.disableJarJsps(false); AppEngineWebXmlProjectStageConfiguration configuration = builder.build(); List<String> expected = ImmutableList.of("stage", source.toString(), destination.toString()); staging.stageStandard(configuration); verify(appCfgRunner, times(1)).run(eq(expected)); }
Example #12
Source File: VersionsTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void startTest() throws ProcessHandlerException, AppEngineException, IOException { appEngineVersions.start(getVersionConfig()); List<String> args = Arrays.asList( "app", "versions", "start", "v1", "v2", "--service", "myService", "--project", "myProject"); verify(gcloudRunner, times(1)).run(eq(args), isNull()); }
Example #13
Source File: VersionsTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void stopTest() throws ProcessHandlerException, AppEngineException, IOException { Versions appEngineVersion = new Versions(gcloudRunner); appEngineVersion.stop(getVersionConfig()); List<String> args = Arrays.asList( "app", "versions", "stop", "v1", "v2", "--service", "myService", "--project", "myProject"); verify(gcloudRunner, times(1)).run(eq(args), isNull()); }
Example #14
Source File: Gcloud.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** * Returns the list of Cloud SDK Components and their settings, reported by the current gcloud * installation. Unlike other methods in this class that call gcloud, this method always uses a * synchronous ProcessRunner and will block until the gcloud process returns. * * @throws ProcessHandlerException when process runner encounters an error * @throws JsonSyntaxException when the cloud SDK output cannot be parsed * @throws CloudSdkNotFoundException when the Cloud SDK is not installed where expected * @throws CloudSdkOutOfDateException when the installed Cloud SDK is too old */ public List<CloudSdkComponent> getComponents() throws ProcessHandlerException, JsonSyntaxException, CloudSdkNotFoundException, CloudSdkOutOfDateException, CloudSdkVersionFileException, IOException { sdk.validateCloudSdk(); // gcloud components list --show-versions --format=json List<String> command = new ImmutableList.Builder<String>() .add("components", "list") .addAll(GcloudArgs.get("show-versions", true)) .addAll(GcloudArgs.get("format", "json")) .build(); String componentsJson = runCommand(command); return CloudSdkComponent.fromJsonList(componentsJson); }
Example #15
Source File: VersionsTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void deleteTest() throws ProcessHandlerException, AppEngineException, IOException { Versions appEngineVersion = new Versions(gcloudRunner); appEngineVersion.delete(getVersionConfig()); List<String> args = Arrays.asList( "app", "versions", "delete", "v1", "v2", "--service", "myService", "--project", "myProject"); verify(gcloudRunner, times(1)).run(eq(args), isNull()); }
Example #16
Source File: Deployment.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** * Common configuration deployment function. * * @param filename Yaml file that we want to deploy (cron.yaml, dos.yaml, etc) * @param configuration Deployment configuration */ @VisibleForTesting void deployConfig(String filename, DeployProjectConfigurationConfiguration configuration) throws AppEngineException { Preconditions.checkNotNull(configuration); Preconditions.checkNotNull(configuration.getAppEngineDirectory()); Path deployable = configuration.getAppEngineDirectory().resolve(filename); Preconditions.checkArgument( Files.isRegularFile(deployable), deployable.toString() + " does not exist."); List<String> arguments = new ArrayList<>(); arguments.add("app"); arguments.add("deploy"); arguments.add(deployable.toAbsolutePath().toString()); arguments.addAll(GcloudArgs.get("server", configuration.getServer())); arguments.addAll(GcloudArgs.get("project", configuration.getProjectId())); try { runner.run(arguments, null); } catch (ProcessHandlerException | IOException ex) { throw new AppEngineException(ex); } }
Example #17
Source File: VersionsTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void listTest_dontHideNoTraffic() throws ProcessHandlerException, AppEngineException, IOException { Versions appEngineVersion = new Versions(gcloudRunner); appEngineVersion.list(getListConfig(false)); List<String> args = Arrays.asList( "app", "versions", "list", "--service", "myService", "--no-hide-no-traffic", "--project", "myProject"); verify(gcloudRunner, times(1)).run(eq(args), isNull()); }
Example #18
Source File: DeploymentTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testDeploy_booleanFlags() throws AppEngineException, ProcessHandlerException, IOException { DeployConfiguration configuration = DeployConfiguration.builder(Collections.singletonList(appYaml1)) .promote(false) .stopPreviousVersion(false) .build(); deployment.deploy(configuration); List<String> expectedCommand = ImmutableList.of( "app", "deploy", appYaml1.toString(), "--no-promote", "--no-stop-previous-version"); verify(gcloudRunner, times(1)).run(eq(expectedCommand), isNull()); }
Example #19
Source File: VersionsTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void listTest_doHideNoTraffic() throws ProcessHandlerException, AppEngineException, IOException { Versions appEngineVersion = new Versions(gcloudRunner); appEngineVersion.list(getListConfig(true)); List<String> args = Arrays.asList( "app", "versions", "list", "--service", "myService", "--hide-no-traffic", "--project", "myProject"); verify(gcloudRunner, times(1)).run(eq(args), isNull()); }
Example #20
Source File: AppCfgRunnerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testRun() throws InvalidJavaSdkException, ProcessHandlerException, AppEngineJavaComponentsNotInstalledException, IOException { AppCfgRunner appCfgRunner = new AppCfgRunner.Factory(processBuilderFactory).newRunner(sdk, processHandler); appCfgRunner.run(ImmutableList.of("some", "command")); Mockito.verify(processBuilder) .command( ImmutableList.of( javaExecutablePath.toString(), "-cp", appengineToolsJar.toString(), "com.google.appengine.tools.admin.AppCfg", "some", "command")); Mockito.verify(processBuilder).start(); Mockito.verifyNoMoreInteractions(processBuilder); Mockito.verify(processHandler).handleProcess(process); Assert.assertEquals(appengineJavaSdkPath.toString(), System.getProperty("appengine.sdk.root")); }
Example #21
Source File: ConfigReader.java From app-maven-plugin with Apache License 2.0 | 6 votes |
/** Return gcloud config property for project, or error out if not found. */ public String getProjectId() { try { String gcloudProject = gcloud.getConfig().getProject(); if (gcloudProject == null || gcloudProject.trim().isEmpty()) { throw new RuntimeException("Project was not found in gcloud config"); } return gcloudProject; } catch (CloudSdkNotFoundException | CloudSdkOutOfDateException | CloudSdkVersionFileException | IOException | ProcessHandlerException ex) { throw new RuntimeException("Failed to read project from gcloud config", ex); } }
Example #22
Source File: AppCfgRunner.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** * Executes an App Engine SDK CLI command. * * @throws AppEngineJavaComponentsNotInstalledException when the App Engine Java components are * not installed in the Cloud SDK * @throws InvalidJavaSdkException java not found */ public void run(List<String> args) throws ProcessHandlerException, AppEngineJavaComponentsNotInstalledException, InvalidJavaSdkException, IOException { sdk.validateAppEngineJavaComponents(); sdk.validateJdk(); // App Engine Java Sdk requires this system property to be set. // TODO: perhaps we should send this in directly to the command instead of changing the global // state here (see DevAppServerRunner) System.setProperty("appengine.sdk.root", sdk.getAppEngineSdkForJavaPath().toString()); List<String> command = new ArrayList<>(); command.add(sdk.getJavaExecutablePath().toString()); command.add("-cp"); command.add(sdk.getAppEngineToolsJar().toString()); command.add("com.google.appengine.tools.admin.AppCfg"); command.addAll(args); logger.info("submitting command: " + Joiner.on(" ").join(command)); ProcessBuilder processBuilder = processBuilderFactory.newProcessBuilder(); processBuilder.command(command); Process process = processBuilder.start(); processHandler.handleProcess(process); }
Example #23
Source File: DeployAllMojoIntegrationTest.java From app-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeployAllStandard() throws IOException, VerificationException, CloudSdkNotFoundException, ProcessHandlerException { Verifier verifier = new StandardVerifier("testDeployStandard"); // execute with staging directory not present verifier.executeGoals(Arrays.asList("package", "appengine:deployAll")); // verify verifier.verifyErrorFreeLog(); verifier.verifyTextInLog("Detected App Engine standard environment application"); verifier.verifyTextInLog("GCLOUD: Deployed service"); verifier.verifyTextInLog("GCLOUD: Custom routings have been updated."); verifier.verifyTextInLog("GCLOUD: DoS protection has been updated."); verifier.verifyTextInLog("GCLOUD: Indexes are being rebuilt. This may take a moment."); verifier.verifyTextInLog("GCLOUD: Cron jobs have been updated."); verifier.verifyTextInLog("GCLOUD: Task queues have been updated."); // cleanup deleteService("standard-project"); }
Example #24
Source File: DeployTargetResolver.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
/** * Process user configuration of "projectId". If set to GCLOUD_CONFIG then read from gcloud's * global state. If set but not a keyword then just return the set value. */ public String getProject(String configString) { if (configString == null || configString.trim().isEmpty() || configString.equals(APPENGINE_CONFIG)) { throw new GradleException(PROJECT_ERROR); } if (configString.equals(GCLOUD_CONFIG)) { try { String gcloudProject = cloudSdkOperations.getGcloud().getConfig().getProject(); if (gcloudProject == null || gcloudProject.trim().isEmpty()) { throw new GradleException("Project was not found in gcloud config"); } return gcloudProject; } catch (IOException | CloudSdkOutOfDateException | ProcessHandlerException | CloudSdkNotFoundException | CloudSdkVersionFileException ex) { throw new GradleException("Failed to read project from gcloud config", ex); } } return configString; }
Example #25
Source File: DeployMojoIntegrationTest.java From app-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeployStandard() throws IOException, VerificationException, CloudSdkNotFoundException, ProcessHandlerException { Verifier verifier = new StandardVerifier("testDeployStandard"); // execute with staging directory not present verifier.executeGoal("package"); verifier.executeGoal("appengine:deploy"); // verify verifier.verifyErrorFreeLog(); verifier.verifyTextInLog("Detected App Engine standard environment application"); verifier.verifyTextInLog("GCLOUD: Deployed service"); // cleanup deleteService("standard-project"); }
Example #26
Source File: AppEngineStandardPluginIntegrationTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDeploy() throws CloudSdkNotFoundException, IOException, ProcessHandlerException, UnsupportedOsException { BuildResult buildResult = GradleRunner.create() .withProjectDir(testProjectDir.getRoot()) .withPluginClasspath() .withArguments("appengineDeploy", "--stacktrace") .build(); Assert.assertThat( buildResult.getOutput(), CoreMatchers.containsString("Deployed service [standard-project]")); deleteProject(); }
Example #27
Source File: DevServerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testWorkingDirectory_fallbackIfOneProject() throws ProcessHandlerException, AppEngineException, IOException { RunConfiguration configuration = RunConfiguration.builder(ImmutableList.of(java8Service)).build(); devServer.run(configuration); verify(devAppServerRunner).run(any(), any(), any(), eq(java8Service) /* workingDirectory */); }
Example #28
Source File: DevServerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testWorkingDirectory_noFallbackIfManyProjects() throws ProcessHandlerException, AppEngineException, IOException { RunConfiguration configuration = RunConfiguration.builder(ImmutableList.of(java8Service, java8Service)).build(); devServer.run(configuration); verify(devAppServerRunner).run(any(), any(), any(), eq(null) /* workingDirectory */); }
Example #29
Source File: DevServerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testPrepareCommand_appEngineWebXmlEnvironmentVariables() throws AppEngineException, ProcessHandlerException, IOException { RunConfiguration configuration = RunConfiguration.builder(ImmutableList.of(java8Service1EnvVars)).build(); List<String> expectedFlags = ImmutableList.of( "--allow_remote_shutdown", "--disable_update_check", "--no_java_agent", java8Service1EnvVars.toString()); List<String> expectedJvmArgs = ImmutableList.of("-Duse_jetty9_runtime=true", "-D--enable_all_permissions=true"); Map<String, String> expectedConfigurationEnvironment = ImmutableMap.of("key1", "val1", "key2", "val2"); Map<String, String> expectedEnvironment = ImmutableMap.<String, String>builder() .putAll(expectedConfigurationEnvironment) .putAll(expectedJava8Environment) .build(); devServer.run(configuration); verify(devAppServerRunner, times(1)) .run( expectedJvmArgs, expectedFlags, expectedEnvironment, java8Service1EnvVars /* workingDirectory */); }
Example #30
Source File: AbstractMojoIntegrationTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
protected void deleteService(String service) throws CloudSdkNotFoundException, IOException, ProcessHandlerException { CloudSdk cloudSdk = new CloudSdk.Builder().build(); Gcloud.builder(cloudSdk) .build() .runCommand(Arrays.asList("app", "services", "delete", service)); }