def test_postTestInvariants(self): # A LayerIsolationError should be raised if the app server dies in the # middle of a test. LayerProcessController.setConfig() LayerProcessController.startAppServer() pid = LayerProcessController.appserver.pid os.kill(pid, signal.SIGTERM) LayerProcessController.appserver.wait() self.assertRaises(LayerIsolationError, LayerProcessController.postTestInvariants)
def test_postTestInvariants(self): # A LayerIsolationError should be raised if the app server dies in the # middle of a test. LayerProcessController.setConfig() LayerProcessController.startAppServer() pid = LayerProcessController.appserver.pid os.kill(pid, signal.SIGTERM) LayerProcessController.appserver.wait() self.assertRaises(LayerIsolationError, LayerProcessController.postTestInvariants)
def setup(): # This code needs to be run after other zcml setup happens in # runlaunchpad, so it is passed in as a callable. We set up layers # here because we need to control fixtures within this process, and # because we want interactive tests to be as similar as possible to # tests run in the testrunner. # Note that this changes the config instance-name, with the result # that the configuration of utilities may become invalidated. # XXX Robert Collins, bug=883980: In short, we should derive the # other services from the test runner, rather than duplicating # the work of test setup within the slave appserver. That will # permit reuse of the librarian, DB, rabbit etc, and # correspondingly easier assertions and inspection of interactions # with other services. That would mean we do not need to set up rabbit # or the librarian here: the test runner would control and take care # of that. BaseLayer.setUp() teardowns.append(BaseLayer.tearDown) RabbitMQLayer.setUp() teardowns.append(RabbitMQLayer.tearDown) # We set up the database here even for the test suite because we want # to be able to control the database here in the subprocess. It is # possible to do that when setting the database up in the parent # process, but it is messier. This is simple. installFakeConnect() teardowns.append(uninstallFakeConnect) DatabaseLayer.setUp() teardowns.append(DatabaseLayer.tearDown) # The Librarian needs access to the database, so setting it up here # where we are setting up the database makes the most sense. LibrarianLayer.setUp() teardowns.append(LibrarianLayer.tearDown) # Switch to the appserver config. fixture = ConfigUseFixture(BaseLayer.appserver_config_name) fixture.setUp() teardowns.append(fixture.cleanUp) # Interactive tests always need this. We let functional tests use # a local one too because of simplicity. LayerProcessController.startSMTPServer() teardowns.append(LayerProcessController.stopSMTPServer) if interactive_tests: root_url = config.appserver_root_url() print '*' * 70 print 'In a few seconds, go to ' + root_url + '/+yuitest' print '*' * 70
def test_postTestInvariants_dbIsReset(self): # The database should be reset by the test invariants. LayerProcessController.setConfig() LayerProcessController.startAppServer() LayerProcessController.postTestInvariants() # XXX: Robert Collins 2010-10-17 bug=661967 - this isn't a reset, its # a flag that it *needs* a reset, which is actually quite different; # the lack of a teardown will leak databases. self.assertEquals(True, LaunchpadTestSetup()._reset_db)
def test_postTestInvariants_dbIsReset(self): # The database should be reset by the test invariants. LayerProcessController.setConfig() LayerProcessController.startAppServer() LayerProcessController.postTestInvariants() # XXX: Robert Collins 2010-10-17 bug=661967 - this isn't a reset, its # a flag that it *needs* a reset, which is actually quite different; # the lack of a teardown will leak databases. self.assertEquals(True, LaunchpadTestSetup()._reset_db)
def test_stopAppServer(self): # Test that stopping the app server kills the process and remove the # PID file. LayerProcessController.setConfig() LayerProcessController.startAppServer() pid = LayerProcessController.appserver.pid pid_file = pidfile_path('launchpad', LayerProcessController.appserver_config) LayerProcessController.stopAppServer() self.assertRaises(OSError, os.kill, pid, 0) self.failIf(os.path.exists(pid_file), "PID file wasn't removed") self.failUnless(LayerProcessController.appserver is None, "appserver class attribute wasn't reset")
def test_stopAppServer(self): # Test that stopping the app server kills the process and remove the # PID file. LayerProcessController.setConfig() LayerProcessController.startAppServer() pid = LayerProcessController.appserver.pid pid_file = pidfile_path('launchpad', LayerProcessController.appserver_config) LayerProcessController.stopAppServer() self.assertRaises(OSError, os.kill, pid, 0) self.failIf(os.path.exists(pid_file), "PID file wasn't removed") self.failUnless(LayerProcessController.appserver is None, "appserver class attribute wasn't reset")
def tearDown(self): super(LayerProcessControllerTestCase, self).tearDown() # Stop both servers. It's okay if they aren't running. LayerProcessController.stopSMTPServer() LayerProcessController.stopAppServer()
def tearDown(self): super(LayerProcessControllerTestCase, self).tearDown() # Stop both servers. It's okay if they aren't running. LayerProcessController.stopSMTPServer() LayerProcessController.stopAppServer()