Navigation Menu

Skip to content

Commit

Permalink
Bigquery and crash timestamp bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
destijl committed Nov 17, 2015
1 parent d6abf8d commit 7eb57dd
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 8 deletions.
16 changes: 16 additions & 0 deletions gui/plugins/crash_view_test.py
Expand Up @@ -146,6 +146,22 @@ def testClientCrashedFlowInHunt(self):
"Crash Message",
"Client killed during transaction"])

def testHuntClientCrashesTabShowsDatesInUTC(self):
with self.ACLChecksDisabled():
self.SetUpCrashedFlowInHunt()

self.Open("/")

# Go to hunt manager, select a hunt, open "Crashes" tab.
self.Click("css=a[grrtarget=ManageHunts]")
self.WaitUntil(self.IsTextPresent, "SampleHunt")
self.Click("css=td:contains('SampleHunt')")
self.Click("css=li[heading=Crashes]")

self.WaitUntil(
self.IsElementPresent,
"css=grr-hunt-crashes dt:contains('Timestamp') ~ dd:contains('UTC')")


def main(argv):
# Run the full test suite
Expand Down
30 changes: 26 additions & 4 deletions gui/plugins/flow_management_test.py
Expand Up @@ -38,6 +38,14 @@ def Start(self):
next_state="End")


class FlowWithOneLogStatement(flow.GRRFlow):
"""Flow that logs a single statement."""

@flow.StateHandler(next_state="End")
def Start(self):
self.Log("I do log.")


class FlowWithOneStatEntryResult(flow.GRRFlow):
"""Test flow that calls SendReply once with a StatEntry value."""

Expand Down Expand Up @@ -153,17 +161,31 @@ def testLogsCanBeOpenedByClickingOnLogsTab(self):
# RecursiveTestFlow doesn't send any results back.
with self.ACLChecksDisabled():
for _ in test_lib.TestFlowHelper(
"RecursiveTestFlow", self.action_mock,
"FlowWithOneLogStatement", self.action_mock,
client_id=self.client_id, token=self.token):
pass

self.Open("/#c=C.0000000000000001")
self.Click("css=a:contains('Manage launched flows')")
self.Click("css=td:contains('RecursiveTestFlow')")
self.Click("css=td:contains('FlowWithOneLogStatement')")
self.Click("css=li[heading=Log]")

self.WaitUntil(self.IsTextPresent, "I do log.")

def testLogTimestampsArePresentedInUTC(self):
with self.ACLChecksDisabled():
with test_lib.FakeTime(42):
for _ in test_lib.TestFlowHelper(
"FlowWithOneLogStatement", self.action_mock,
client_id=self.client_id, token=self.token):
pass

self.Open("/#c=C.0000000000000001")
self.Click("css=a:contains('Manage launched flows')")
self.Click("css=td:contains('FlowWithOneLogStatement')")
self.Click("css=li[heading=Log]")

self.WaitUntil(self.IsTextPresent, "Subflow call 1")
self.WaitUntil(self.IsTextPresent, "Subflow call 0")
self.WaitUntil(self.IsTextPresent, "1970-01-01 00:00:42 UTC")

def testResultsAreDisplayedInResultsTab(self):
with self.ACLChecksDisabled():
Expand Down
26 changes: 26 additions & 0 deletions gui/plugins/hunt_view_test.py
Expand Up @@ -738,6 +738,18 @@ def testLogsTabFiltersLogsByString(self):
self.WaitUntilNot(self.IsTextPresent, "Finished reading " +
str(client_id.Add("fs/os/tmp/evil.txt")))

def testLogsTabShowsDatesInUTC(self):
with self.ACLChecksDisabled():
with self.CreateSampleHunt() as hunt:
with test_lib.FakeTime(42):
hunt.Log("I do log.")

self.Open("/#main=ManageHunts")
self.Click("css=td:contains('GenericHunt')")
self.Click("css=li[heading=Log]")

self.WaitUntil(self.IsTextPresent, "1970-01-01 00:00:42 UTC")

def testErrorsTabShowsErrorsFromAllClients(self):
with self.ACLChecksDisabled():
self.SetupHuntDetailView(failrate=1)
Expand All @@ -749,6 +761,20 @@ def testErrorsTabShowsErrorsFromAllClients(self):
for client_id in self.client_ids:
self.WaitUntil(self.IsTextPresent, str(client_id))

def testErrorsTabShowsDatesInUTC(self):
with self.ACLChecksDisabled():
with self.CreateSampleHunt() as hunt:
with test_lib.FakeTime(42):
# Log an error just with some random traceback.
hunt.LogClientError(self.client_ids[0], "Client Error 1",
traceback.format_exc())

self.Open("/#main=ManageHunts")
self.Click("css=td:contains('GenericHunt')")
self.Click("css=li[heading=Errors]")

self.WaitUntil(self.IsTextPresent, "1970-01-01 00:00:42 UTC")

def testErrorsTabFiltersErrorsByString(self):
with self.ACLChecksDisabled():
self.SetupHuntDetailView(failrate=1)
Expand Down
2 changes: 1 addition & 1 deletion gui/static/angular-components/flow/flow-log.html
Expand Up @@ -9,7 +9,7 @@
</thead>
<tbody>
<tr grr-paged-filtered-table grr-aff4-items-provider aff4-path="::controller.logsUrn">
<td class="table-cell proto_key"><nobr>{$ ::item.age * 1000 | date:'medium' $}</nobr></td>
<td class="table-cell proto_key"><grr-timestamp value="::item.age" /></td>
<td class="table-cell proto_key"><grr-semantic-value value="::item.value.flow_name" /></td>
<td class="table-cell proto_key"><grr-semantic-value value="::item.value.urn" /></td>
<td class="table-cell proto_key"><grr-semantic-value value="::item.value.log_message" /></td>
Expand Down
2 changes: 1 addition & 1 deletion gui/static/angular-components/hunt/hunt-errors.html
Expand Up @@ -9,7 +9,7 @@
</thead>
<tbody>
<tr grr-paged-filtered-table grr-aff4-items-provider aff4-path="::controller.errorsUrn">
<td ng-class="::{proto_key: $index % 2 == 0}"><nobr>{$ ::item.age / 1000 | date:'medium' $}</nobr></td>
<td ng-class="::{proto_key: $index % 2 == 0}"><grr-timestamp value="::item.age" /></td>
<td ng-class="::{proto_key: $index % 2 == 0}"><grr-client-urn value="::item.value.client_id" /></td>
<td ng-class="::{proto_key: $index % 2 == 0}">{$ ::item.value.backtrace.value $}</td>
<td ng-class="::{proto_key: $index % 2 == 0}">{$ ::item.value.log_message.value $}</td>
Expand Down
2 changes: 1 addition & 1 deletion gui/static/angular-components/hunt/hunt-log.html
Expand Up @@ -12,7 +12,7 @@
<tr grr-paged-filtered-table page-size="100"
grr-aff4-items-provider aff4-path="::controller.logsUrn"
transform-items="controller.transformItems(items)">
<td ng-class="::{proto_key: item.highlighted}"><nobr>{$ ::item.age / 1000 | date:'medium' $}</nobr></td>
<td ng-class="::{proto_key: item.highlighted}"><grr-timestamp value="::item.age" /></td>
<td ng-class="::{proto_key: item.highlighted}"><grr-client-urn value="::item.value.client_id.value" /></td>
<td ng-class="::{proto_key: item.highlighted}">{$ ::item.shortUrn.value $}</td>
<td ng-class="::{proto_key: item.highlighted}">{$ ::item.value.flow_name.value $}</td>
Expand Down
5 changes: 4 additions & 1 deletion lib/output_plugins/bigquery_plugin.py
Expand Up @@ -74,9 +74,12 @@ class BigQueryOutputPlugin(output_plugin.OutputPluginWithOutputStreams):
"uint32": "INTEGER",
"uint64": "INTEGER"}

def __init__(self, *args, **kwargs):
super(BigQueryOutputPlugin, self).__init__(*args, **kwargs)
self.temp_output_trackers = {}

def Initialize(self):
super(BigQueryOutputPlugin, self).Initialize()
self.temp_output_trackers = {}
# The last job ID if there was a failure. Keys are output types.
self.state.Register("output_jobids", {})
# Total number of BigQuery upload failures.
Expand Down

0 comments on commit 7eb57dd

Please sign in to comment.