Hello Devs & Contributors,
We recently committed a refactor of the MesosTest suite and underlying
"Cluster" abstraction. This affects almost every existing test and future
test, so here's a summary of what has changed and what you should be aware
of:
- The purpose of the refactor is to make the entire test suite more
resilient to flaky tests. Before, every test that used the "
MesosTest::StartMaster" and "MesosTest::StartSlave" helpers also needed
to have "Shutdown()" at the end of the test. If the test failed an
assertion or expectation, it would exit before "Shutdown()" and would
very likely segfault, or hit a "__cxa_pure_virtual__" and exit with a
cryptic stack trace.
- The signatures of "MesosTest::StartMaster" and "MesosTest::StartSlave"
have changed. Both test helpers now return a "
Try<Owned<cluster::Master/Slave>" Instead of a "Try<PID<Master/Slave>>".
To way to access the "PID" was changed from ".get()" to ".get()->pid".
- "Shutdown()" has been removed from MesosTest. It is no longer
necessary.
- The MasterDetector has been exposed at the top-level for all slaves.
This slave dependency was originally populated by the "Cluster" abstraction
(which held both Masters and Slaves). In most cases, it will be sufficient
to create the detector like:
Owned<MasterDetector> detector = master->createDetector();
- If you need to restart the master in the middle of a test, just reset
the underlying "Owned" pointer. i.e:
master->reset();
master = StartMaster();
Note: We can't assign master before resetting the pointer. This is a
limitation related to supporting multiple masters in tests, which is
currently not possible.
- If you need to restart the slave in the middle of a test, there are
several ways:
- To clean up any containers associated with that slave:
slave = StartSlave(...);
Or:
slave.reset();
slave = StartSlave(...);
- To stop a slave without container cleanup (equivalent to the
original "MesosTest::Stop()"), use:
slave->terminate();
Or:
slave->shutdown();
These two methods emulate turning off the slave, but have slightly
different semantics. "Terminate" generally emulates a crash. "Shutdown"
emulates a graceful exit.
If you have any further questions, feel free to ask. There are still quite
a few improvements to make, but those will likely be less disruptive.
~Joseph