Skip to content

Commit

Permalink
Merge pull request #1 from andrewkroh/merge_773
Browse files Browse the repository at this point in the history
Add Topbeat system test for process username
  • Loading branch information
tsg committed Jan 26, 2016
2 parents 228d863 + 4276ab7 commit fc3590e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion topbeat/tests/system/test_procs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from topbeat import BaseTest

import getpass
import re

import os

"""
Contains tests for per process statistics.
Expand Down Expand Up @@ -31,6 +32,7 @@ def test_procs(self):
assert re.match("(?i).*topbeat.test(.exe)? -e -c", output["proc.cmdline"])
assert isinstance(output["proc.state"], basestring)
assert isinstance(output["proc.cpu.start_time"], basestring)
self.check_username(output["proc.username"])

for key in [
"proc.pid",
Expand All @@ -49,3 +51,14 @@ def test_procs(self):
"proc.mem.rss_p",
]:
assert type(output[key]) in [int, float]

def check_username(self, observed, expected = None):
if expected == None:
expected = getpass.getuser()

if os.name == 'nt':
parts = observed.split("\\", 2)
assert len(parts) == 2, "Expected proc.username to be of form DOMAIN\username, but was %s" % observed
observed = parts[1]

assert expected == observed, "proc.username = %s, but expected %s" % (observed, expected)

0 comments on commit fc3590e

Please sign in to comment.