/** * Create test plan. * * @param string $size size of the test plan. * @param string $proxy proxy url * @param string $port (optional) port to be used for proxy server. * @param bool $enable only enable it. */ public function create_test_plan($size, $proxy = "localhost:9090", $port = '', $enable = false) { global $CFG, $DB; // Check if site is initialised for performance testing. //TODO: // Drop old testplan data dir, ensuring we have fresh data everytime we run the tool. util::drop_dir(util::get_tool_dir(), true); // Initialise BrowserMobProxy. $browsermobproxy = new browsermobproxyclient($proxy); // Use the proxy server url now. $proxyurl = $browsermobproxy->create_connection($port); echo "Proxy server running at: " . $proxyurl . PHP_EOL; // Create behat.yml. util::create_test_feature($size, array(), $proxyurl); util::set_option('size', $size); // Run test plan. if (!$enable) { $cmd = "vendor/bin/behat --config " . util::get_tool_dir() . DIRECTORY_SEPARATOR . 'behat.yml '; echo "Run " . PHP_EOL . ' - ' . $cmd . PHP_EOL . PHP_EOL; } else { $this->run_plan_features(); } // Close BrowserMobProxy connection. $browsermobproxy->close_connection(); }
/** * After suite event. * * @param SuiteEvent $event * @AfterSuite */ public static function after_suite(SuiteEvent $event) { $browsermobproxy = new browsermobproxyclient(util::get_option('proxyurl')); $browsermobproxy->close_connection(); echo PHP_EOL . "Test plan has been generated under:" . PHP_EOL; echo " - " . util::get_final_testplan_path() . PHP_EOL; }