com.klarna.hiverunner.config.HiveRunnerConfig Java Examples

The following examples show how to use com.klarna.hiverunner.config.HiveRunnerConfig. 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: StandaloneHiveRunner.java    From HiveRunner with Apache License 2.0 6 votes vote down vote up
private TestRule getHiveRunnerConfigRule(Object target) {
    return new TestRule() {
        @Override
        public Statement apply(Statement base, Description description) {
            Set<Field> fields = ReflectionUtils.getAllFields(target.getClass(),
                    Predicates.and(
                            withAnnotation(HiveRunnerSetup.class),
                            withType(HiveRunnerConfig.class)));

            Preconditions.checkState(fields.size() <= 1,
                    "Exact one field of type HiveRunnerConfig should to be annotated with @HiveRunnerSetup");

            /*
             Override the config with test case config. Taking care to not replace the config instance since it
              has been passes around and referenced by some of the other test rules.
              */
            if (!fields.isEmpty()) {
                config.override(ReflectionUtils
                        .getFieldValue(target, fields.iterator().next().getName(), HiveRunnerConfig.class));
            }

            return base;
        }
    };
}
 
Example #2
Source File: HiveRunnerCore.java    From HiveRunner with Apache License 2.0 5 votes vote down vote up
/**
 * Traverses the test case annotations. Will inject a HiveShell in the test case that envelopes the HiveServer.
 */
HiveShellContainer createHiveServerContainer(List<? extends Script> scripts, Object testCase,
    Path baseDir, HiveRunnerConfig config)
    throws IOException {

  HiveServerContext context = new StandaloneHiveServerContext(baseDir, config);

  return buildShell(scripts, testCase, config, context);
}
 
Example #3
Source File: HiveServerContainerTest.java    From HiveRunner with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException {
    basedir = Files.createTempDirectory("HiveServerContainerTest");
    StandaloneHiveServerContext context = new StandaloneHiveServerContext(basedir, new HiveRunnerConfig());
    container = new HiveServerContainer(context);
    container.init(new HashMap<>(), new HashMap<>());
}
 
Example #4
Source File: ThrowOnTimeout.java    From HiveRunner with Apache License 2.0 5 votes vote down vote up
public static TestRule create(final HiveRunnerConfig config, final Object target) {
    return new TestRule() {
        @Override
        public Statement apply(Statement base, Description description) {
            return new ThrowOnTimeout(base, config, target);
        }
    };
}
 
Example #5
Source File: HiveRunnerExtension.java    From HiveRunner with Apache License 2.0 5 votes vote down vote up
private void setupConfig(Object target) {
  Set<Field> fields = ReflectionUtils.getAllFields(target.getClass(),
      Predicates.and(
          withAnnotation(HiveRunnerSetup.class),
          withType(HiveRunnerConfig.class)));

  Preconditions.checkState(fields.size() <= 1,
      "Only one field of type HiveRunnerConfig should be annotated with @HiveRunnerSetup");

  if (!fields.isEmpty()) {
    config.override(ReflectionUtils
        .getFieldValue(target, fields.iterator().next().getName(), HiveRunnerConfig.class));
  }
}
 
Example #6
Source File: HiveRunnerCore.java    From HiveRunner with Apache License 2.0 5 votes vote down vote up
private HiveShellContainer buildShell(List<? extends Script> scripts, Object testCase, HiveRunnerConfig config,
    HiveServerContext context) throws IOException {
  HiveServerContainer hiveTestHarness = new HiveServerContainer(context);

  HiveShellBuilder hiveShellBuilder = new HiveShellBuilder();
  hiveShellBuilder.setCommandShellEmulation(config.getCommandShellEmulator());

  HiveShellField shellSetter = loadScriptUnderTest(testCase, hiveShellBuilder);
  if (scripts != null) {
    hiveShellBuilder.overrideScriptsUnderTest(scripts);
  }

  hiveShellBuilder.setHiveServerContainer(hiveTestHarness);

  loadAnnotatedResources(testCase, hiveShellBuilder);

  loadAnnotatedProperties(testCase, hiveShellBuilder);

  loadAnnotatedSetupScripts(testCase, hiveShellBuilder);

  // Build shell
  HiveShellContainer shell = hiveShellBuilder.buildShell();

  // Set shell
  shellSetter.setShell(shell);

  if (shellSetter.isAutoStart()) {
    shell.start();
  }
  return shell;
}
 
Example #7
Source File: HiveRunnerShimV3.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void setCommandShellEmulation(HiveShellBuilder builder, HiveRunnerConfig config) throws Exception {
	Method method = HiveRunnerConfig.class.getDeclaredMethod("getCommandShellEmulation");
	Object emulation = method.invoke(config);
	Class emulationClz = Class.forName("com.klarna.hiverunner.CommandShellEmulation");
	method = HiveShellBuilder.class.getDeclaredMethod("setCommandShellEmulation", emulationClz);
	method.invoke(builder, emulation);
}
 
Example #8
Source File: HiveRunnerShimV4.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void setCommandShellEmulation(HiveShellBuilder builder, HiveRunnerConfig config) throws Exception {
	Method method = config.getClass().getDeclaredMethod("getCommandShellEmulator");
	Object emulator = method.invoke(config);
	Class emulatorClz = Class.forName("com.klarna.hiverunner.sql.cli.CommandShellEmulator");
	method = builder.getClass().getDeclaredMethod("setCommandShellEmulation", emulatorClz);
	method.invoke(builder, emulator);
}
 
Example #9
Source File: HiveRunnerShimV3.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void setCommandShellEmulation(HiveShellBuilder builder, HiveRunnerConfig config) throws Exception {
	Method method = HiveRunnerConfig.class.getDeclaredMethod("getCommandShellEmulation");
	Object emulation = method.invoke(config);
	Class emulationClz = Class.forName("com.klarna.hiverunner.CommandShellEmulation");
	method = HiveShellBuilder.class.getDeclaredMethod("setCommandShellEmulation", emulationClz);
	method.invoke(builder, emulation);
}
 
Example #10
Source File: HiveRunnerShimV4.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void setCommandShellEmulation(HiveShellBuilder builder, HiveRunnerConfig config) throws Exception {
	Method method = config.getClass().getDeclaredMethod("getCommandShellEmulator");
	Object emulator = method.invoke(config);
	Class emulatorClz = Class.forName("com.klarna.hiverunner.sql.cli.CommandShellEmulator");
	method = builder.getClass().getDeclaredMethod("setCommandShellEmulation", emulatorClz);
	method.invoke(builder, emulator);
}
 
Example #11
Source File: FlinkStandaloneHiveServerContext.java    From flink with Apache License 2.0 4 votes vote down vote up
FlinkStandaloneHiveServerContext(TemporaryFolder basedir, HiveRunnerConfig hiveRunnerConfig, int hmsPort) {
	this.basedir = basedir;
	this.hiveRunnerConfig = hiveRunnerConfig;
	this.hmsPort = hmsPort;
}
 
Example #12
Source File: StandaloneHiveRunner.java    From HiveRunner with Apache License 2.0 4 votes vote down vote up
protected HiveRunnerConfig getHiveRunnerConfig() {
  return config;
}
 
Example #13
Source File: ThrowOnTimeout.java    From HiveRunner with Apache License 2.0 4 votes vote down vote up
public ThrowOnTimeout(Statement originalStatement, HiveRunnerConfig config, Object target) {
    this.originalStatement = originalStatement;
    this.config = config;
    this.target = target;
}
 
Example #14
Source File: StandaloneHiveServerContext.java    From HiveRunner with Apache License 2.0 4 votes vote down vote up
public StandaloneHiveServerContext(Path basedir, HiveRunnerConfig hiveRunnerConfig) {
    this.basedir = basedir;
    this.hiveRunnerConfig = hiveRunnerConfig;
}
 
Example #15
Source File: FlinkStandaloneHiveServerContext.java    From flink with Apache License 2.0 4 votes vote down vote up
FlinkStandaloneHiveServerContext(TemporaryFolder basedir, HiveRunnerConfig hiveRunnerConfig, int hmsPort) {
	this.basedir = basedir;
	this.hiveRunnerConfig = hiveRunnerConfig;
	this.hmsPort = hmsPort;
}
 
Example #16
Source File: HiveRunnerShim.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Sets CommandShellEmulation for HiveShellBuilder.
 */
void setCommandShellEmulation(HiveShellBuilder builder, HiveRunnerConfig config) throws Exception;
 
Example #17
Source File: HiveRunnerShim.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Sets CommandShellEmulation for HiveShellBuilder.
 */
void setCommandShellEmulation(HiveShellBuilder builder, HiveRunnerConfig config) throws Exception;