public static function setUpBeforeClass() { $dbName = false; if (!empty($GLOBALS['PIWIK_BENCHMARK_DATABASE'])) { $dbName = $GLOBALS['PIWIK_BENCHMARK_DATABASE']; } // connect to database self::createTestConfig(); self::connectWithoutDatabase(); // create specified fixture (global var not set, use default no-data fixture (see end of this file)) if (empty($GLOBALS['PIWIK_BENCHMARK_FIXTURE'])) { $fixtureName = 'Piwik_Test_Fixture_EmptyOneSite'; } else { $fixtureName = 'Piwik_Test_Fixture_' . $GLOBALS['PIWIK_BENCHMARK_FIXTURE']; } self::$fixture = new $fixtureName(); // figure out if the desired fixture has already been setup, and if not empty the database $installedFixture = false; try { if (isset(self::$fixture->tablesPrefix)) { Config::getInstance()->database['tables_prefix'] = self::$fixture->tablesPrefix; } Db::query("USE " . $dbName); $installedFixture = \Piwik\Option::get('benchmark_fixture_name'); } catch (Exception $ex) { // ignore } $createEmptyDatabase = $fixtureName != $installedFixture; parent::_setUpBeforeClass($dbName, $createEmptyDatabase); // if we created an empty database, setup the fixture if ($createEmptyDatabase) { self::$fixture->setUp(); \Piwik\Option::set('benchmark_fixture_name', $fixtureName); } }
public function setUp() { // add one thousand sites $allIdSites = array(); for ($i = 0; $i < 1000; ++$i) { $allIdSites[] = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}"); } $urls = array(); for ($i = 0; $i != 3; ++$i) { $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1); $title = "page view " . ($i - 1) . " / " . ($i + 1); $urls[$url] = $title; } $visitTimes = array(); $date = Date::factory($this->date); for ($i = 0; $i != 4; ++$i) { $visitTimes[] = $date->addHour($i)->getDatetime(); } // add 12000 visits (3 visitors with 4 visits each for each site) w/ 3 pageviews each on one day foreach ($visitTimes as $visitTime) { foreach ($allIdSites as $idSite) { for ($visitor = 0; $visitor != 3; ++$visitor) { $t = BenchmarkTestCase::getLocalTracker($idSite); $ip = "157.5.6." . ($visitor + 1); $t->setIp($ip); $t->setNewVisitorId(); $t->setForceVisitDateTime($visitTime); foreach ($urls as $url => $title) { $t->setUrl($url); $t->doTrackPageView($title); } } } } }
public function setUp() { // add one site Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/"); // add two goals $goals = API::getInstance(); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5); $goals->addGoal($this->idSite, 'all', 'url', 'thing2', 'contains'); $start = Date::factory($this->date); $dates = array(); for ($day = 0; $day != 31; ++$day) { $dates[] = $start->addDay($day); } $t = BenchmarkTestCase::getLocalTracker($this->idSite); $actionNum = 0; foreach ($dates as $date) { for ($visitNum = 0; $visitNum != 1000; ++$visitNum) { if ($visitNum % 2 == 0) { $url = "http://whatever.com/{$actionNum}/0/1/2/3/4/5/6/7/8/9"; $referrerUrl = "http://google.com/?q={$actionNum}"; } else { $url = "http://whatever.com/thing2/{$actionNum}/0/1/2/3/4/5/6/7/8/9"; $referrerUrl = "http://"; } $title = "A page title / {$actionNum} / 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 /9"; $t->setNewVisitorId(); $t->setForceVisitDateTime($date); $t->setUrl($url); $t->setUrlReferrer($referrerUrl); Fixture::checkResponse($t->doTrackPageView($title)); ++$actionNum; } } }
public function setUp() { $sitesManager = Piwik_SitesManager_API::getInstance(); $goals = Piwik_Goals_API::getInstance(); // add one thousand sites $allIdSites = array(); for ($i = 0; $i < 1000; ++$i) { $allIdSites[] = IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}"); } // add goals to 500 sites $idGoals = array(); foreach ($allIdSites as $idSite) { if ($idSite % 2 == 0) { $idGoal1 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5); $idGoal2 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains'); $idGoals[$idSite] = array($idGoal1, $idGoal2); } else { $idGoals[$idSite] = array(); } } $urls = array(); for ($i = 0; $i != 3; ++$i) { $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1); $title = "page view " . ($i - 1) . " / " . ($i + 1); $urls[$url] = $title; } $visitTimes = array(); $date = Piwik_Date::factory($this->date); for ($i = 0; $i != 4; ++$i) { $visitTimes[] = $date->addHour($i)->getDatetime(); } // add 12000 visits (3 visitors with 4 visits each for each site) w/ 3 pageviews each on one day foreach ($visitTimes as $visitTime) { foreach ($allIdSites as $idSite) { for ($visitor = 0; $visitor != 3; ++$visitor) { $t = BenchmarkTestCase::getLocalTracker($this->idSite); $ip = "157.5.6." . ($visitor + 1); $t->setIp($ip); $t->setForceVisitDateTime($visitTime); foreach ($urls as $url => $title) { $t->setUrl($url); $t->doTrackPageView($title); } } } } }
public function setUp() { for ($i = 0; $i != $this->siteCount; ++$i) { $idSite = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}", $siteUrl = "http://site{$i}.com/"); API::getInstance()->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5); } // track one visit for each site $t = BenchmarkTestCase::getLocalTracker(1); $t->setForceVisitDateTime(Date::factory($this->date)->addHour(6)); for ($idSite = 1; $idSite < $this->siteCount + 1; ++$idSite) { $ip = "157.5.6.4"; $t->setIp($ip); $t->setNewVisitorId(); $t->setIdSite($idSite); $t->setUrl("http://site" . ($idSite - 1) . ".com/page.html"); $t->doTrackPageView('page title'); } }
public function setUp() { // add one site IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/"); // add two goals $goals = Piwik_Goals_API::getInstance(); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5); $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains'); $urls = array(); for ($i = 0; $i != 3; ++$i) { $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1); $title = "page view " . ($i - 1) . " / " . ($i + 1); $urls[$url] = $title; } $visitTimes = array(); $date = Piwik_Date::factory($this->date); for ($month = 0; $month != 12; ++$month) { for ($day = 0; $day != 25; ++$day) { $hour = $time * 31 / 60.0; $visitTimes[] = $date->addPeriod($month, 'MONTH')->addDay($day)->getDatetime(); } } // add 12,000 visits (1 visit a day from 40 visitors for 25 days of every month) w/ 3 pageviews each foreach ($visitTimes as $visitTime) { for ($visitor = 0; $visitor != 40; ++$visitor) { $t = BenchmarkTestCase::getLocalTracker($this->idSite); $ip = "157.5.6." . ($visitor + 1); $t->setIp($ip); $t->setForceVisitDateTime($visitTime); foreach ($urls as $url => $title) { $t->setUrl($url); $t->doTrackPageView($title); } } } }
public function setUp() { BenchmarkTestCase::deleteArchiveTables(); }