Ejemplo n.º 1
0
 def _update_task(self, appname, server, why):
     """Creates/updates application task with the new placement."""
     # Servers in the cell have full control over task node.
     if self.events_dir:
         if server:
             appevents.post(
                 self.events_dir,
                 traceevents.ScheduledTraceEvent(instanceid=appname,
                                                 where=server,
                                                 why=why))
         else:
             appevents.post(
                 self.events_dir,
                 traceevents.PendingTraceEvent(instanceid=appname, why=why))
Ejemplo n.º 2
0
    def test_scheduled(self, stdout_mock):
        """Test printing Scheduled event.
        """
        event = events.ScheduledTraceEvent(timestamp=1,
                                           source='tests',
                                           instanceid='proid.foo#123',
                                           where='here',
                                           why='because',
                                           payload={'foo': 'bar'})

        self.trace_printer.process(event)

        self.assertEqual(
            stdout_mock.getvalue(), 'Thu, 01 Jan 1970 00:00:01+0000 - '
            'proid.foo#123 scheduled on here: because\n')
Ejemplo n.º 3
0
 def test_scheduled(self):
     """Scheduled event operations.
     """
     event = events.ScheduledTraceEvent(
         timestamp=1,
         source='tests',
         instanceid='proid.foo#123',
         where='here',
         why='because',
         payload={'foo': 'bar'}
     )
     self.assertEqual(
         event.to_dict(),
         {
             'event_type': 'scheduled',
             'timestamp': 1,
             'source': 'tests',
             'instanceid': 'proid.foo#123',
             'where': 'here',
             'why': 'because',
             'payload': {'foo': 'bar'},
         }
     )
     self.assertEqual(
         event.to_data(),
         (
             1,
             'tests',
             'proid.foo#123',
             'scheduled',
             'here:because',
             {'foo': 'bar'},
         )
     )
     self.assertEqual(
         event,
         events.ScheduledTraceEvent.from_data(
             timestamp=1,
             source='tests',
             instanceid='proid.foo#123',
             event_type='scheduled',
             event_data='here:because',
             payload={'foo': 'bar'}
         )
     )