Skip to content
Kevin Lin edited this page Oct 20, 2017 · 3 revisions

Overview

Tests exist for purposes of tracking regressions introduced by new changes by several developers. They are a tool to measure the stability and correctness of the RDFS codebase.

Tests will use the Google Test framework.

Adding a new test

  1. New tests should be placed in the ~/rdfs/test directory.
  2. Modify CMakeLists.txt to create an executable to run the test.
  3. Modify .ci/test/main.sh to invoke the test executable. Keep it alphabetized.

If you add a new test, please tag a reviewer on the blame here.

Running tests locally

  1. Build the project.
  2. cd build/test
  3. ./TestExecutableName

Running tests on CI

Push a commit to your feature/bug development branch. CI will automatically run all tests in .ci/test/main.sh in a fresh environment.

Testing in RDFS

A beginner's guide to using Google Test is located here.

Namenode

Run the namenode executable from build/rice-namenode. Then run something like hdfs dfs -fs hdfs://localhost:port/ -mkdir foo where port is the port used by the namenode (it will print the port used)

Datanode

Run the datanode executable from build/rice-datanode. Then run something like hdfs dfsadmin -shutdownDatanode hdfs://localhost:port/ where port is the port used by the datanode (it will print the port used)

End-to-end acceptance test

  1. Pull the code and build (as explained above).
  2. Run zookeeper (from ~, it’s sudo zookeeper/bin/zkServer.sh start). This will run in the background.
  3. Run namenode (rdfs/build/rice-namenode/namenode). This will run in the foreground.
  4. Run datanode (rdfs/build/rice-datanode/datanode). This will run in the foreground.
  5. Create a file with hdfs dfs -fs hdfs://localhost:5351 -copyFromLocal localFile /filename
  6. Try to cat that file with hdfs dfs -fs hdfs://localhost:5351 -cat /filename

Mocking

Google Mock should be used in conjunction with Google Test.

Google Mock is not a testing framework, but a framework for writing C++ mock
classes. A mock class is simplified version of a real class that can be created to aid with testing. However, Google Mock does do an automatic verification of expectations.

The typical flow is:

  1. Import the Google Mock names you need to use. All Google Mock names are in the testing namespace unless they are macros or otherwise noted.

  2. Create the mock objects.

  3. Optionally, set the default actions of the mock objects.

  4. Set your expectations on the mock objects (How will they be called? What will they do?).

  5. Exercise code that uses the mock objects; if necessary, check the result using Google Test assertions.

  6. When a mock objects is destructed, Google Mock automatically verifies that all expectations on it have been satisfied.

You should read through all of the Google Mock documentation located at (/googletest/googlemock/docs/) before using it:

  • ForDummies -- start here if you are new to Google Mock.
  • CheatSheet -- a quick reference.
  • CookBook -- recipes for doing various tasks using Google Mock.

Clone this wiki locally