private VoltCompiler compileForDDLTest2(String ddl) throws Exception {
   String ddlPath = getPathForSchema(ddl);
   final VoltCompiler compiler = new VoltCompiler();
   boolean success = compiler.compileFromDDL(testout_jar, ddlPath);
   assertTrue("Catalog compile failed!", success);
   return compiler;
 }
Example #2
0
  public boolean compile(
      final VoltCompiler compiler,
      final String jarPath,
      final String voltRoot,
      final DeploymentInfo deployment,
      final boolean ppdEnabled,
      final String snapshotPath,
      final String ppdPrefix) {
    assert (jarPath != null);
    assert (deployment == null || deployment.sitesPerHost >= 1);
    assert (deployment == null || deployment.hostCount >= 1);

    String deploymentVoltRoot = voltRoot;
    if (deployment != null) {
      if (voltRoot == null) {
        String voltRootPath = "/tmp/" + System.getProperty("user.name");
        java.io.File voltRootFile = new java.io.File(voltRootPath);
        if (!voltRootFile.exists()) {
          if (!voltRootFile.mkdir()) {
            throw new RuntimeException(
                "Unable to create voltdbroot \"" + voltRootPath + "\" for test");
          }
        }
        if (!voltRootFile.isDirectory()) {
          throw new RuntimeException(
              "voltdbroot \"" + voltRootPath + "\" for test exists but is not a directory");
        }
        if (!voltRootFile.canRead()) {
          throw new RuntimeException(
              "voltdbroot \"" + voltRootPath + "\" for test exists but is not readable");
        }
        if (!voltRootFile.canWrite()) {
          throw new RuntimeException(
              "voltdbroot \"" + voltRootPath + "\" for test exists but is not writable");
        }
        if (!voltRootFile.canExecute()) {
          throw new RuntimeException(
              "voltdbroot \"" + voltRootPath + "\" for test exists but is not writable");
        }
        deploymentVoltRoot = voltRootPath;
      }
    }
    m_voltRootPath = deploymentVoltRoot;

    // Add the DDL in the transformer to the schema files before compilation
    try {
      addLiteralSchema(transformer.toString());
      transformer = new StringBuffer();
    } catch (IOException e) {
      e.printStackTrace();
      return false;
    }

    String[] schemaPath = m_schemas.toArray(new String[0]);

    compiler.setProcInfoOverrides(m_procInfoOverrides);
    if (m_diagnostics != null) {
      compiler.enableDetailedCapture();
    }

    boolean success = false;
    try {
      success = compiler.compileFromDDL(jarPath, schemaPath);
    } catch (VoltCompilerException e1) {
      e1.printStackTrace();
      return false;
    }

    m_diagnostics = compiler.harvestCapturedDetail();
    if (m_compilerDebugPrintStream != null) {
      if (success) {
        compiler.summarizeSuccess(m_compilerDebugPrintStream, m_compilerDebugPrintStream, jarPath);
      } else {
        compiler.summarizeErrors(m_compilerDebugPrintStream, m_compilerDebugPrintStream);
      }
    }
    if (deployment != null) {
      try {
        m_pathToDeployment = writeDeploymentFile(deploymentVoltRoot, deployment);
      } catch (Exception e) {
        System.out.println("Failed to create deployment file in testcase.");
        e.printStackTrace();
        System.out.println("hostcount: " + deployment.hostCount);
        System.out.println("sitesPerHost: " + deployment.sitesPerHost);
        System.out.println("replication: " + deployment.replication);
        System.out.println("voltRoot: " + deploymentVoltRoot);
        System.out.println("ppdEnabled: " + ppdEnabled);
        System.out.println("snapshotPath: " + snapshotPath);
        System.out.println("ppdPrefix: " + ppdPrefix);
        System.out.println("adminEnabled: " + deployment.useCustomAdmin);
        System.out.println("adminPort: " + deployment.adminPort);
        System.out.println("adminOnStartup: " + deployment.adminOnStartup);

        // sufficient to escape and fail test cases?
        throw new RuntimeException(e);
      }
    }

    return success;
  }