msmith - in flumotion/trunk: . flumotion/test

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Wed Jul 18 16:53:09 CEST 2007


Author: msmith
Date: Wed Jul 18 16:53:06 2007
New Revision: 5324

Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/test/test_manager_depgraph.py
   flumotion/trunk/flumotion/test/test_manager_manager.py
Log:
        * flumotion/test/test_manager_depgraph.py:
        * flumotion/test/test_manager_manager.py:
          Fix up testsuite for depgraph changes.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Wed Jul 18 16:53:06 2007
@@ -1,5 +1,11 @@
 2007-07-18  Michael Smith <msmith at fluendo.com>
 
+	* flumotion/test/test_manager_depgraph.py:
+	* flumotion/test/test_manager_manager.py:
+	  Fix up testsuite for depgraph changes.
+
+2007-07-18  Michael Smith <msmith at fluendo.com>
+
 	* flumotion/manager/depgraph.py:
 	  Remove Feeder, Eater classes, which are unused.
 	  Make state dict contain a callable as well as a boolean for each DAG

Modified: flumotion/trunk/flumotion/test/test_manager_depgraph.py
==============================================================================
--- flumotion/trunk/flumotion/test/test_manager_depgraph.py	(original)
+++ flumotion/trunk/flumotion/test/test_manager_depgraph.py	Wed Jul 18 16:53:06 2007
@@ -47,6 +47,19 @@
         ret.set("config", conf)
         return ret
 
+    def setUp(self):
+        self._setup = []
+        self._started = []
+
+    def _addComponent(self, dg, component):
+        def setup(component):
+            name = component.get('name')
+            self._setup.append(name)
+        def started(component):
+            name = component.get('name')
+            self._started.append(name)
+
+        dg.addComponent(component, setup, started)
         
     def testVideoOnlyOnOneWorker(self):
         """
@@ -55,6 +68,7 @@
         """
         
         dg = DepGraph()
+
         videotest_defs = ["video-test", "videotest", "default", 
             ["video-test:default"], [] ]
         videoenc_defs = ["video-encoder", "theora-encoder", "default",
@@ -69,11 +83,11 @@
         muxer = self._createComponent(muxer_defs)
         streamer = self._createComponent(streamer_defs)
         
-        dg.addComponent(videotest)
-        dg.addComponent(videoenc)
-        dg.addComponent(muxer)
-        dg.addComponent(streamer)
-        dg.addClockMaster(videotest)
+        self._addComponent(dg, videotest)
+        self._addComponent(dg, videoenc)
+        self._addComponent(dg, muxer)
+        self._addComponent(dg, streamer)
+        dg.addClockMaster(videotest, lambda x: None)
         dg.mapEatersToFeeders()
         
         # now check depgraph is correct
@@ -120,27 +134,39 @@
                     #    self.failUnless(postindex > jobindex)
                         
         # Nothing should be started yet, because no workers logged in
-        tobestarted = dg.whatShouldBeStarted()
-        self.assertEquals(len(tobestarted), 0)
+        self.assertEquals(len(self._setup), 0)
+        self.assertEquals(len(self._started), 0)
+
         dg.setWorkerStarted("default")
-        
-        # What is told to be started should be everything except the worker
-        # which is already started
-        #tobestarted = dg.whatShouldBeStarted()
-        #self.assertEquals(len(tobestarted), len(startorder)-1)
-        #dg.setJobStarted(videotest)
-        #tobestarted = dg.whatShouldBeStarted()
-        #self.assertEquals(len(tobestarted), len(startorder)-2)
-        #self.failUnless((videotest, "JOB") not in tobestarted)
+        # Just starting the worker isn't enough...
+        self.assertEquals(len(self._setup), 0)
+        self.assertEquals(len(self._started), 0)
 
+        dg.setJobStarted(videotest)
         dg.setJobStarted(videoenc)
         dg.setJobStarted(muxer)
         dg.setJobStarted(streamer)
-        tobestarted = dg.whatShouldBeStarted()
-        # go through tobestarted and check if state of all is 0
-        for obj in tobestarted:
-            self.failUnless(dg._state[obj] == False)
-        
+
+        # videotest should have been told to setup now, but nothing else yet.
+        self.assertEquals(self._setup, ['video-test'])
+
+        dg.setComponentSetup(videotest)
+        dg.setClockMasterStarted(videotest)
+        # Now we should have video-encoder asked to setup, and videotest 
+        # asked to start.
+        self.assertEquals(self._setup, ['video-test', 'video-encoder'])
+        self.assertEquals(self._started, ['video-test'])
+
+        dg.setComponentSetup(videoenc)
+        dg.setComponentSetup(muxer)
+        dg.setComponentStarted(videotest)
+        # And now everything should be in _setup, and videotest and videoenc in
+        # _started
+        self.assertEquals(self._setup, 
+            ['video-test', 'video-encoder', 'muxer-video', 'http-video'])
+        self.assertEquals(self._started, 
+            ['video-test', 'video-encoder'])
+
     def testBrokenDepGraph(self):
         dg = DepGraph()
         videotest_defs = ["video-test", "videotest", "default", ["video-test:default"], []]
@@ -150,9 +176,10 @@
         videotest = self._createComponent(videotest_defs)
         muxer = self._createComponent(muxer_defs)
 
-        self.assertRaises(KeyError, dg.addClockMaster, videotest)
-        dg.addComponent(videotest)
-        dg.addComponent(muxer)
+        self.assertRaises(KeyError, dg.addClockMaster, videotest, 
+            lambda x: None)
+        dg.addComponent(videotest, lambda x: None, lambda x: None)
+        dg.addComponent(muxer, lambda x: None, lambda x: None)
         # lets be naughty and try to mapEatersToFeeders before whole flow is in
         self.assertRaises(errors.ComponentConfigError, dg.mapEatersToFeeders)
 
@@ -172,11 +199,11 @@
         muxer = self._createComponent(muxer_defs)
         streamer = self._createComponent(streamer_defs)
         
-        dg.addComponent(videotest)
-        dg.addComponent(videoenc)
-        dg.addComponent(muxer)
-        dg.addComponent(streamer)
-        dg.addClockMaster(videotest)
+        self._addComponent(dg, videotest)
+        self._addComponent(dg, videoenc)
+        self._addComponent(dg, muxer)
+        self._addComponent(dg, streamer)
+        dg.addClockMaster(videotest, lambda x: None)
         dg.mapEatersToFeeders()
         
         # now cleanup depgraph
@@ -185,8 +212,10 @@
         dg.removeComponent(muxer)
         dg.removeComponent(videoenc)
 
-        started = dg.whatShouldBeStarted()
-        assert(len(started) == 0)
+        # Nothing should be started.
+        self.assertEquals(len(self._setup), 0)
+        self.assertEquals(len(self._started), 0)
+
         # let's make sure worker has no children
         assert(dg._dag.hasNode("default", "WORKER"))
         workerchildren = dg._dag.getChildrenTyped("default", "WORKER")
@@ -202,19 +231,21 @@
         for node in dg._dag.sort():
             assert(dg._dag.hasNode(node[0], node[1]))
         
-        dg.addComponent(videotest)
-        dg.addComponent(videoenc)
-        dg.addComponent(muxer)
-        dg.addComponent(streamer)
-        dg.addClockMaster(videotest)
+        self._addComponent(dg, videotest)
+        self._addComponent(dg, videoenc)
+        self._addComponent(dg, muxer)
+        self._addComponent(dg, streamer)
+        dg.addClockMaster(videotest, lambda x: None)
         dg.mapEatersToFeeders()
         
-        # Nothing should be started yet, because no workers logged in
-        tobestarted = dg.whatShouldBeStarted()
-        self.assertEquals(len(tobestarted), 0)
+        # Nothing should be started, no worker logged in
+        self.assertEquals(len(self._setup), 0)
+        self.assertEquals(len(self._started), 0)
+
         dg.setWorkerStarted("default")
 
-        startorder = dg.whatShouldBeStarted()
+        #startorder = dg.whatShouldBeStarted()
+        startorder = dg._dag.sort()
         # now check that the jobs are before the componentsetup
         # and componentsetup before componentready
         # and componentready before any clock master in that component

Modified: flumotion/trunk/flumotion/test/test_manager_manager.py
==============================================================================
--- flumotion/trunk/flumotion/test/test_manager_manager.py	(original)
+++ flumotion/trunk/flumotion/test/test_manager_manager.py	Wed Jul 18 16:53:06 2007
@@ -598,11 +598,6 @@
             self.failUnless('converter-ogg-theora' in names)
             self.failUnless('streamer-ogg-theora' in names)
 
-            # verify that nothing should be started
-            start = self.vishnu._depgraph.whatShouldBeStarted()
-            # should be nothing because we have no worker
-            assert start == []
-            
             # log in a worker and verify components get started
             return self._loginWorker('worker')
 


More information about the flumotion-commit mailing list