Search in sources :

Example 1 with Container

use of org.testcontainers.containers.Container in project alluxio by Alluxio.

the class TableIntegrationTest method execBeeline.

/**
 * Runs a sequence of commands via beeline, within the HMS container.
 *
 * @param commands the list of commands
 */
private static void execBeeline(List<String> commands) throws Exception {
    File file = sFolder.newFile();
    PrintWriter writer = new PrintWriter(file.getAbsolutePath());
    for (String line : commands) {
        writer.println(line);
    }
    writer.close();
    sHms.copyFileToContainer(MountableFile.forHostPath(file.getAbsolutePath()), "/opt/" + file.getName());
    Container.ExecResult result = sHms.execInContainer("/opt/hive/bin/beeline", "-u", "jdbc:hive2://", "-f", "/opt/" + file.getName());
    if (result.getExitCode() != 0) {
        throw new IOException("beeline commands failed. stderr: " + result.getStderr());
    }
}
Also used : Container(org.testcontainers.containers.Container) GenericContainer(org.testcontainers.containers.GenericContainer) IOException(java.io.IOException) File(java.io.File) MountableFile(org.testcontainers.utility.MountableFile) PrintWriter(java.io.PrintWriter)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Container (org.testcontainers.containers.Container)1 GenericContainer (org.testcontainers.containers.GenericContainer)1 MountableFile (org.testcontainers.utility.MountableFile)1