Ejemplo n.º 1
0
 def test_get_state(self):
     actual = os_utilities.get_state()
     actual.pop('reboot_required', None)
     actual.pop('temp', None)
     expected = {
         u'audio',
         u'cost_usd_hour',
         u'cpu_name',
         u'cwd',
         u'disks',
         u'env',
         u'gpu',
         u'ip',
         u'hostname',
         u'nb_files_in_temp',
         u'pid',
         u'python',
         u'ram',
         u'running_time',
         u'ssd',
         u'started_ts',
         u'uptime',
         u'user',
     }
     if sys.platform in ('cygwin', 'win32'):
         expected.add(u'cygwin')
     if sys.platform == 'darwin':
         expected.add(u'xcode')
     if sys.platform == 'win32':
         expected.add(u'integrity')
     if u'quarantined' in actual:
         self.fail(actual[u'quarantined'])
     self.assertEqual(expected, set(actual))
Ejemplo n.º 2
0
 def test_get_state(self):
     actual = os_utilities.get_state()
     actual.pop('temp', None)
     expected = {
         u'audio',
         u'cost_usd_hour',
         u'cpu',
         u'cwd',
         u'disks',
         u'gpu',
         u'ip',
         u'hostname',
         u'locale',
         u'nb_files_in_temp',
         u'pid',
         u'ram',
         u'running_time',
         u'started_ts',
         u'uptime',
         u'user',
     }
     if sys.platform in ('cygwin', 'win32'):
         expected.add(u'cygwin')
     if sys.platform == 'darwin':
         expected.add(u'model')
         expected.add(u'xcode')
     if sys.platform == 'win32':
         expected.add(u'integrity')
     self.assertEqual(expected, set(actual))
Ejemplo n.º 3
0
 def test_get_state(self):
   actual = os_utilities.get_state()
   expected = {
     'cost_usd_hour', 'cwd', 'disks', 'gpu', 'ip', 'hostname', 'ram',
     'running_time', 'started_ts',
   }
   if sys.platform in ('cygwin', 'win32'):
     expected.add('cygwin')
   if sys.platform == 'win32':
     expected.add('integrity')
   self.assertEqual(expected, set(actual))
Ejemplo n.º 4
0
def get_state():
  """Returns dict with a state of the bot reported to the server with each poll.

  It is only for dynamic state that changes while bot is running for information
  for the sysadmins.

  The server can not use this state for immediate scheduling purposes (use
  'dimensions' for that), but it can use it for maintenance and bookkeeping
  tasks.

  See https://code.google.com/p/swarming/wiki/SwarmingMagicValues.
  """
  return os_utilities.get_state()
Ejemplo n.º 5
0
  def test_get_state_android(self):
    self.mock(time, 'time', lambda: os_utilities._STARTED_TS + 1)
    expected_dimensions = dict((k, k) for k in os_utilities.ANDROID_DETAILS)
    props = expected_dimensions.copy()
    props['bar'] = 'foo'
    self.mock(os_utilities, 'get_adb_device_properties_raw', lambda *_: props)

    expected_dimensions['id'] = ['123']
    actual = os_utilities.get_state_android('123')
    expected = {
      'device': {},
      'host': os_utilities.get_state(),
    }
    self.assertEqual(expected, actual)
Ejemplo n.º 6
0
 def test_get_state(self):
   actual = os_utilities.get_state()
   actual.pop('temp', None)
   expected = {
     u'audio', u'cost_usd_hour', u'cpu', u'cwd', u'disks', u'gpu', u'ip',
     u'hostname', u'locale', u'nb_files_in_temp', u'pid', u'ram',
     u'running_time', u'started_ts', u'uptime', u'user',
   }
   if sys.platform in ('cygwin', 'win32'):
     expected.add(u'cygwin')
   if sys.platform == 'darwin':
     expected.add(u'model')
     expected.add(u'xcode')
   if sys.platform == 'win32':
     expected.add(u'integrity')
   self.assertEqual(expected, set(actual))
Ejemplo n.º 7
0
    def test_get_state_android(self):
        self.mock(time, 'time', lambda: os_utilities._STARTED_TS + 1)
        expected_dimensions = dict(
            (k, k) for k in os_utilities.ANDROID_DETAILS)
        props = expected_dimensions.copy()
        props[u'bar'] = u'foo'
        self.mock(os_utilities, 'get_adb_device_properties_raw',
                  lambda *_: props)

        expected_dimensions[u'id'] = [u'123']
        actual = os_utilities.get_state_android('123')
        expected = {
            u'device': {},
            u'host': os_utilities.get_state(),
        }
        self.assertEqual(expected, actual)
Ejemplo n.º 8
0
 def test_get_state(self):
     actual = os_utilities.get_state()
     expected = {
         u'cost_usd_hour',
         u'cwd',
         u'disks',
         u'gpu',
         u'ip',
         u'hostname',
         u'ram',
         u'running_time',
         u'started_ts',
     }
     if sys.platform in ('cygwin', 'win32'):
         expected.add(u'cygwin')
     if sys.platform == 'win32':
         expected.add(u'integrity')
     self.assertEqual(expected, set(actual))
Ejemplo n.º 9
0
def get_state(sleep_streak):
  """Returns dict with a state of the bot reported to the server with each poll.
  """
  try:
    if _in_load_test_mode():
      state = os_utilities.get_state()
      state['dimensions'] = os_utilities.get_dimensions()
    else:
      import bot_config
      state = bot_config.get_state()
      if not isinstance(state, dict):
        state = {'error': state}
  except Exception as e:
    state = {
      'error': '%s\n%s' % (e, traceback.format_exc()[-2048:]),
      'quarantined': True,
    }

  state['sleep_streak'] = sleep_streak
  return state
Ejemplo n.º 10
0
def get_state(sleep_streak):
    """Returns dict with a state of the bot reported to the server with each poll.
  """
    try:
        if _in_load_test_mode():
            state = os_utilities.get_state()
            state['dimensions'] = os_utilities.get_dimensions()
        else:
            import bot_config
            state = bot_config.get_state()
            if not isinstance(state, dict):
                state = {'error': state}
    except Exception as e:
        state = {
            'error': '%s\n%s' % (e, traceback.format_exc()[-2048:]),
            'quarantined': True,
        }

    state['sleep_streak'] = sleep_streak
    return state
Ejemplo n.º 11
0
 def test_get_state(self):
   self.mock(time, 'time', lambda: 126.0)
   expected = os_utilities.get_state()
   expected['sleep_streak'] = 12
   self.assertEqual(expected, bot_main.get_state(12))
Ejemplo n.º 12
0
 def test_get_state(self):
     self.mock(time, 'time', lambda: 126.0)
     expected = os_utilities.get_state()
     expected['sleep_streak'] = 12
     self.assertEqual(expected, bot_main.get_state(12))