You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Joseph Wu <jo...@mesosphere.io> on 2016/03/16 16:03:25 UTC

Recent changes to MesosTest helpers

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

Re: Recent changes to MesosTest helpers

Posted by Vinod Kone <vi...@apache.org>.
This is awesome! Thanks for working on this.

On Wed, Mar 16, 2016 at 9:53 AM, haosdent <ha...@gmail.com> wrote:

> Got it, thank you for explanation.
>
> On Thu, Mar 17, 2016 at 12:51 AM, Joseph Wu <jo...@mesosphere.io> wrote:
>
> > We tried to reduce segfaults of this particular pattern (de-referencing
> > out-of-scope stack variables), as much as possible.  This means the test
> > suite shouldn't crash due to flaky tests anymore.  And the test suite
> > should run to completion each time.
> >
> > (I also replaced a bunch of CHECK_* statements in the tests with
> ASSERT_*.)
> >
> > On Wed, Mar 16, 2016 at 8:27 AM, haosdent <ha...@gmail.com> wrote:
> >
> > > Does it exit like segment when CHECK_xxx failed? Or exit until finish
> all
> > > test cases?
> > > On Mar 16, 2016 11:03 PM, "Joseph Wu" <jo...@mesosphere.io> wrote:
> > >
> > > > 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
> > > >
> > >
> >
>
>
>
> --
> Best Regards,
> Haosdent Huang
>

Re: Recent changes to MesosTest helpers

Posted by haosdent <ha...@gmail.com>.
Got it, thank you for explanation.

On Thu, Mar 17, 2016 at 12:51 AM, Joseph Wu <jo...@mesosphere.io> wrote:

> We tried to reduce segfaults of this particular pattern (de-referencing
> out-of-scope stack variables), as much as possible.  This means the test
> suite shouldn't crash due to flaky tests anymore.  And the test suite
> should run to completion each time.
>
> (I also replaced a bunch of CHECK_* statements in the tests with ASSERT_*.)
>
> On Wed, Mar 16, 2016 at 8:27 AM, haosdent <ha...@gmail.com> wrote:
>
> > Does it exit like segment when CHECK_xxx failed? Or exit until finish all
> > test cases?
> > On Mar 16, 2016 11:03 PM, "Joseph Wu" <jo...@mesosphere.io> wrote:
> >
> > > 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
> > >
> >
>



-- 
Best Regards,
Haosdent Huang

Re: Recent changes to MesosTest helpers

Posted by Joseph Wu <jo...@mesosphere.io>.
We tried to reduce segfaults of this particular pattern (de-referencing
out-of-scope stack variables), as much as possible.  This means the test
suite shouldn't crash due to flaky tests anymore.  And the test suite
should run to completion each time.

(I also replaced a bunch of CHECK_* statements in the tests with ASSERT_*.)

On Wed, Mar 16, 2016 at 8:27 AM, haosdent <ha...@gmail.com> wrote:

> Does it exit like segment when CHECK_xxx failed? Or exit until finish all
> test cases?
> On Mar 16, 2016 11:03 PM, "Joseph Wu" <jo...@mesosphere.io> wrote:
>
> > 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
> >
>

Re: Recent changes to MesosTest helpers

Posted by haosdent <ha...@gmail.com>.
Does it exit like segment when CHECK_xxx failed? Or exit until finish all
test cases?
On Mar 16, 2016 11:03 PM, "Joseph Wu" <jo...@mesosphere.io> wrote:

> 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
>