Exemplo n.º 1
0
def test_empty_ish_perfdata():
    provider = lambda: ''
    with pytest.raises(ValueError):
        perfdata = PerfData.get(provider)

    provider = lambda: PerfData.MAGIC
    with pytest.raises(ValueError):
        perfdata = PerfData.get(provider)
Exemplo n.º 2
0
def test_empty_ish_perfdata():
  provider = lambda: ''
  with pytest.raises(ValueError):
    perfdata = PerfData.get(provider)

  provider = lambda: PerfData.MAGIC
  with pytest.raises(ValueError):
    perfdata = PerfData.get(provider)
Exemplo n.º 3
0
def test_struct_unpack_error():
  provider = lambda: pkgutil.get_data('twitter.common.java', _EXAMPLE_RESOURCE)
  perfdata = PerfData.get(provider)
  assert perfdata is not None

  with mock.patch('struct.unpack') as struct_unpack:
    struct_unpack.side_effect = struct.error('My shit got corrupted!')

    with pytest.raises(perfdata.ParseError):
      perfdata.sample()
Exemplo n.º 4
0
def main(args, options):
    if len(args) > 0:
        app.error('Must provide hsperfdata via -f/-p')

    if options.list:
        print_pids()
        return

    perfdata = None
    if options.filename:
        perfdata = PerfData.get(file_provider())
    elif options.pid:
        perfdata = PerfData.get(pid_provider())

    if perfdata is None:
        app.error('No hsperfdata provider specified!')

    perfdata.sample()
    for key in sorted(perfdata):
        print('%s: %s' % (key, perfdata[key]))
Exemplo n.º 5
0
def test_perfdata_integration():
  provider = lambda: pkgutil.get_data('twitter.common.java', _EXAMPLE_RESOURCE)
  perfdata = PerfData.get(provider)
  assert perfdata is not None
  perfdata.sample()

  assert len(perfdata) > 0
  keys = set(perfdata)
  for key in perfdata:
    assert key in keys
    assert perfdata[key] is not None
Exemplo n.º 6
0
def test_struct_unpack_error():
    provider = lambda: pkgutil.get_data('twitter.common.java',
                                        _EXAMPLE_RESOURCE)
    perfdata = PerfData.get(provider)
    assert perfdata is not None

    with mock.patch('struct.unpack') as struct_unpack:
        struct_unpack.side_effect = struct.error('My shit got corrupted!')

        with pytest.raises(perfdata.ParseError):
            perfdata.sample()
Exemplo n.º 7
0
def main(args, options):
  if len(args) > 0:
    app.error('Must provide hsperfdata via -f/-p')

  if options.list:
    print_pids()
    return

  perfdata = None
  if options.filename:
    perfdata = PerfData.get(file_provider())
  elif options.pid:
    perfdata = PerfData.get(pid_provider())

  if perfdata is None:
    app.error('No hsperfdata provider specified!')

  perfdata.sample()
  for key in sorted(perfdata):
    print('%s: %s' % (key, perfdata[key]))
Exemplo n.º 8
0
def test_perfdata_integration():
    provider = lambda: pkgutil.get_data('twitter.common.java',
                                        _EXAMPLE_RESOURCE)
    perfdata = PerfData.get(provider)
    assert perfdata is not None
    perfdata.sample()

    assert len(perfdata) > 0
    keys = set(perfdata)
    for key in perfdata:
        assert key in keys
        assert perfdata[key] is not None