Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The module reef-tests contains our integration tests. These tests run actual REEF jobs and validate their behavior. Also, they are portable across all runtimes REEF supports. this page documents how to write such integration tests. We use JUnit as the testing framework. However, these tests are not unit tests, but integration tests. Within the test method, we use the REEF client submit a Driver and observe its behavior.

The simplest test

Consider the following simple test:

Code Block
languagejava
titleDriverTest.java
linenumberstrue
public class DriverTest {
  private final TestEnvironment testEnvironment = TestEnvironmentFactory.getNewTestEnvironment();
  @Before
  public void setUp() throws Exception {
    testEnvironment.setUp();
  }
  @Test
  public void testSimpleDriver() throws BindException, InjectionException {
    final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();
    final Configuration driverConfiguration = DriverConfiguration.CONF
        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(DriverTestStartHandler.class))
        .set(DriverConfiguration.DRIVER_IDENTIFIER, "TEST_DriverTest")
        .set(DriverConfiguration.ON_DRIVER_STARTED, DriverTestStartHandler.class)
        .build();
    final LauncherStatus status = this.testEnvironment.run(driverConfiguration);
    Assert.assertTrue("Job state after execution: " + status, status.isSuccess());
  }
  @After
  public void tearDown() throws Exception {
    this.testEnvironment.tearDown();
  }
}

Lines up a very simple driver and in line 16 submits it for execution. Note that the interaction between the test and the actual runtime is mediated via the TestEnvironment interface. This allows us to write integration tests that are portable across all of the runtimes supported.