Skip to content

Commit

Permalink
Refs #3632, add integration test for import script replay tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Feb 27, 2013
1 parent d6a65a6 commit 5dca1a2
Show file tree
Hide file tree
Showing 55 changed files with 809 additions and 193 deletions.
3 changes: 2 additions & 1 deletion misc/log-analytics/import_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@ def invalid_line(line, reason):

hits = []
for lineno, line in enumerate(file):
print("LINE: " + line)
try:
line = line.decode(config.options.encoding)
except UnicodeDecodeError:
Expand Down Expand Up @@ -1449,7 +1450,7 @@ def invalid_line(line, reason):
except UnicodeDecodeError:
invalid_line(line, 'invalid encoding')
continue

print("SUCCESSFUL PARSE")
# Check if the hit must be excluded.
if all((method(hit) for method in self.check_methods)):
hits.append(hit)
Expand Down
19 changes: 19 additions & 0 deletions tests/PHPUnit/Integration/ImportLogsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected static function trackVisits()
{
self::logVisitsWithStaticResolver(self::$tokenAuth);
self::logVisitsWithAllEnabled(self::$tokenAuth);
self::replayLogFile(self::$tokenAuth);
}

/**
Expand Down Expand Up @@ -155,6 +156,23 @@ protected static function logVisitsWithAllEnabled( $token_auth )

self::executeLogImporter($logFile, $opts);
}
public static $output;
/**
* Logs a couple visit using log entries that are tracking requests to a piwik.php file.
* Adds two visits to idSite=1 and two to non-existant sites.
*/
protected static function replayLogFile( $token_auth )
{
$logFile = PIWIK_INCLUDE_PATH.'/tests/resources/fake_logs_replay.log';

$opts = array('--token-auth' => $token_auth,
'--recorders' => '4',
'--recorder-max-payload-size' => '2',
'--replay-tracking' => false);

self::executeLogImporter($logFile, $opts);
echo print_r(self::$output, true);
}

protected static function executeLogImporter( $logFile, $options )
{
Expand All @@ -181,6 +199,7 @@ protected static function executeLogImporter( $logFile, $options )

// run the command
exec($cmd, $output, $result);
self::$output = $output;
if ($result !== 0)
{
throw new Exception("log importer failed: ".implode("\n", $output)."\n\ncommand used: $cmd");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,38 @@
</row>
</subtable>
</row>
<row>
<label> incredible title!</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
</row>
<row>
<label> Piwik Forums</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
</row>
</result>
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,24 @@
<exit_rate>100%</exit_rate>
<url>http://piwik.net/</url>
</row>
<row>
<label>/index.htm</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
<url>http://example.org/index.htm</url>
</row>
<row>
<label>/moved-permanently</label>
<nb_visits>1</nb_visits>
Expand All @@ -404,6 +422,24 @@
<exit_rate>0%</exit_rate>
<url>http://piwik.net/moved-permanently</url>
</row>
<row>
<label>/register.php?0,approve=9a94a02145599</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
<url>http://forum.piwik.org/register.php?0,approve=9a94a02145599</url>
</row>
<row>
<label>/to-an-error</label>
<nb_visits>1</nb_visits>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,38 @@
</row>
</subtable>
</row>
<row>
<label> incredible title!</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
</row>
<row>
<label> Piwik Forums</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
</row>
</result>
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,42 @@
<exit_rate>100%</exit_rate>
<url>http://piwik.net/</url>
</row>
<row>
<label>/index.htm</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
<url>http://example.org/index.htm</url>
</row>
<row>
<label>/register.php?0,approve=9a94a02145599</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
<url>http://forum.piwik.org/register.php?0,approve=9a94a02145599</url>
</row>
<row>
<label>/temp-redirect</label>
<nb_visits>1</nb_visits>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,38 @@
</row>
</subtable>
</row>
<row>
<label> incredible title!</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
</row>
<row>
<label> Piwik Forums</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
</row>
</result>
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<result />
<result>
<row>
<label>/index.htm</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
<url>http://example.org/index.htm</url>
</row>
</result>
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,24 @@
<exit_rate>100%</exit_rate>
<url>http://piwik.net/</url>
</row>
<row>
<label>/index.htm</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
<url>http://example.org/index.htm</url>
</row>
<row>
<label>/moved-permanently</label>
<nb_visits>1</nb_visits>
Expand All @@ -404,6 +422,24 @@
<exit_rate>0%</exit_rate>
<url>http://piwik.net/moved-permanently</url>
</row>
<row>
<label>/register.php?0,approve=9a94a02145599</label>
<nb_visits>1</nb_visits>
<nb_hits>1</nb_hits>
<sum_time_spent>0</sum_time_spent>
<entry_nb_visits>1</entry_nb_visits>
<entry_nb_actions>1</entry_nb_actions>
<entry_sum_visit_length>0</entry_sum_visit_length>
<entry_bounce_count>1</entry_bounce_count>
<exit_nb_visits>1</exit_nb_visits>
<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
<sum_daily_entry_nb_uniq_visitors>1</sum_daily_entry_nb_uniq_visitors>
<sum_daily_exit_nb_uniq_visitors>1</sum_daily_exit_nb_uniq_visitors>
<avg_time_on_page>0</avg_time_on_page>
<bounce_rate>100%</bounce_rate>
<exit_rate>100%</exit_rate>
<url>http://forum.piwik.org/register.php?0,approve=9a94a02145599</url>
</row>
<row>
<label>/temp-redirect</label>
<nb_visits>1</nb_visits>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<result>
<nb_pageviews>22</nb_pageviews>
<nb_uniq_pageviews>22</nb_uniq_pageviews>
<nb_pageviews>24</nb_pageviews>
<nb_uniq_pageviews>24</nb_uniq_pageviews>
<nb_downloads>3</nb_downloads>
<nb_uniq_downloads>3</nb_uniq_downloads>
<nb_outlinks>0</nb_outlinks>
Expand Down
Loading

0 comments on commit 5dca1a2

Please sign in to comment.