-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Test product tests launcher #17875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test product tests launcher #17875
Changes from all commits
d0ea876
2543c04
7468873
2eb1a80
d01c513
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,8 +37,6 @@ | |
| import picocli.CommandLine.Mixin; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileDescriptor; | ||
| import java.io.FileOutputStream; | ||
| import java.io.PrintStream; | ||
| import java.io.UnsupportedEncodingException; | ||
| import java.nio.charset.Charset; | ||
|
|
@@ -232,7 +230,7 @@ public Execution( | |
| this.outputBuilder = describeOptions.format.outputBuilderFactory.get(); | ||
|
|
||
| try { | ||
| this.out = new PrintStream(new FileOutputStream(FileDescriptor.out), true, Charset.defaultCharset().name()); | ||
| this.out = new PrintStream(System.out, true, Charset.defaultCharset().name()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is causing to actually write to stderr because of https://github.com/airlift/airlift/blob/master/log-manager/src/main/java/io/airlift/log/Logging.java#L139 This commit should be reverted. Logging to stderr here makes this fail to read any output: https://github.com/trinodb/trino/blob/master/.github/bin/build-pt-matrix-from-impacted-connectors.py#L108
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| catch (UnsupportedEncodingException e) { | ||
| throw new IllegalStateException("Could not create print stream", e); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.trino.tests.product.launcher.cli; | ||
|
|
||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.IOException; | ||
| import java.io.PrintStream; | ||
| import java.nio.file.Files; | ||
|
|
||
| import static io.trino.tests.product.launcher.cli.Launcher.execute; | ||
| import static java.nio.charset.StandardCharsets.UTF_8; | ||
| import static java.util.Objects.requireNonNull; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @Test(singleThreaded = true) | ||
| public class TestInvocations | ||
| { | ||
| @Test | ||
| public void testEnvironmentList() | ||
| { | ||
| InvocationResult invocationResult = invokeLauncher("env", "list"); | ||
|
|
||
| assertThat(invocationResult.exitCode()).isEqualTo(0); | ||
| assertThat(invocationResult.output()) | ||
| .contains("Available environments:") | ||
| .contains("multinode"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSuiteList() | ||
| { | ||
| InvocationResult invocationResult = invokeLauncher("suite", "list"); | ||
|
|
||
| assertThat(invocationResult.exitCode()).isEqualTo(0); | ||
| assertThat(invocationResult.output()) | ||
| .contains("Available suites:") | ||
| .contains("suite-1"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDescribeEnvironment() | ||
| throws IOException | ||
| { | ||
| InvocationResult invocationResult = invokeLauncher( | ||
| "env", "describe", | ||
| "--server-package", Files.createTempFile("server", ".tar.gz").toString(), | ||
| // This is known to work for both arm and x86 | ||
| "--environment", "multinode-postgresql"); | ||
|
|
||
| assertThat(invocationResult.exitCode()).isEqualTo(0); | ||
| assertThat(invocationResult.output()) | ||
| .contains("Environment 'multinode-postgresql' file mounts:"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDescribeSuite() | ||
| throws IOException | ||
| { | ||
| InvocationResult invocationResult = invokeLauncher( | ||
| "suite", "describe", | ||
| "--server-package", Files.createTempFile("server", ".tar.gz").toString(), | ||
| "--suite", "suite-1"); | ||
|
|
||
| assertThat(invocationResult.exitCode()).isEqualTo(0); | ||
| assertThat(invocationResult.output()) | ||
| .contains("Suite 'suite-1' with configuration 'config-default' consists of following test runs"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testEnvUpDown() | ||
| throws IOException | ||
| { | ||
| InvocationResult upResult = invokeLauncher( | ||
| "env", "up", | ||
| "--server-package", Files.createTempFile("server", ".tar.gz").toString(), | ||
| "--without-trino", | ||
| "--background", | ||
| "--bind", | ||
| "off", | ||
| // This is known to work for both arm and x86 | ||
| "--environment", "multinode-postgresql"); | ||
|
|
||
| assertThat(upResult.exitCode()).isEqualTo(0); | ||
| InvocationResult downResult = invokeLauncher("env", "down"); | ||
| assertThat(downResult.exitCode()).isEqualTo(0); | ||
| } | ||
|
|
||
| public static InvocationResult invokeLauncher(String... args) | ||
| { | ||
| Launcher launcher = new Launcher(); | ||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
|
|
||
| try (CaptureOutput ignored = new CaptureOutput(out)) { | ||
| int exitCode = execute(launcher, new Launcher.LauncherBundle(), args); | ||
| return new InvocationResult(exitCode, out.toString(UTF_8)); | ||
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("UnusedVariable") | ||
| private record InvocationResult(int exitCode, String output) {} | ||
|
|
||
| private static class CaptureOutput | ||
| implements AutoCloseable | ||
| { | ||
| private final PrintStream originalOut; | ||
| private final PrintStream originalErr; | ||
|
|
||
| public CaptureOutput(ByteArrayOutputStream out) | ||
| { | ||
| PrintStream stream = new PrintStream(requireNonNull(out, "out is null")); | ||
| this.originalOut = System.out; | ||
| this.originalErr = System.err; | ||
| System.setOut(stream); | ||
| System.setErr(stream); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() | ||
| { | ||
| System.setOut(originalOut); | ||
| System.setErr(originalErr); | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.