diff --git a/app/Http/Controllers/MetaGerSearch.php b/app/Http/Controllers/MetaGerSearch.php index e1aaf1ba5001a500bc4f717b233dd2f3d96e925d..032d739bdd2a8d0c2fcdd33a8fa08e10008eb1bd 100644 --- a/app/Http/Controllers/MetaGerSearch.php +++ b/app/Http/Controllers/MetaGerSearch.php @@ -88,9 +88,13 @@ class MetaGerSearch extends Controller $metager->startSearch($timings); # Versuchen die Ergebnisse der Quicktips zu laden - $quicktipResults = $quicktips->loadResults(); - if (!empty($timings)) { - $timings["Loaded Quicktip Results"] = microtime(true) - $time; + if($quicktips !== null) { + $quicktipResults = $quicktips->loadResults(); + if (!empty($timings)) { + $timings["Loaded Quicktip Results"] = microtime(true) - $time; + } + } else { + $quicktipResults = []; } $metager->waitForMainResults(); @@ -119,7 +123,6 @@ class MetaGerSearch extends Controller $engine->markNew(); } } - try { Cache::put("loader_" . $metager->getSearchUid(), [ "metager" => [ diff --git a/app/Http/Controllers/Stresstest.php b/app/Http/Controllers/Stresstest.php new file mode 100644 index 0000000000000000000000000000000000000000..a4114a8c6c4c9f7766c78c55a406ead2d65aa7f0 --- /dev/null +++ b/app/Http/Controllers/Stresstest.php @@ -0,0 +1,31 @@ +<?php + +namespace App\Http\Controllers; + +use App; +use App\MetaGer; +use Cache; +use Illuminate\Http\Request; +use LaravelLocalization; +use Log; +use View; + +/* The controller uses the MetaGers dummy engine ( documentation: https:\/\/gitlab.metager.de\/open-source\/dummy-engine ) +* to generate a list of test results for stress testing purposes at "/admin/stress". +* For local testing go to config/stress.json and change sumas->dummy->host to "dummy-nginx". +* To activate browser and human verfication use the following route: "/admin/stress/verify". +*/ +class Stresstest extends MetaGerSearch +{ + public function index(Request $request, MetaGer $metager, $timing = false) + { + # adds / replaces query input with a random string to avoid cached results + $request->merge(["eingabe" => "test" . rand()]); + + # deactivates adgoal + $metager->setDummy(true); + $metager->setAdgoalHash(true); + + parent::search($request, $metager, $timing); + } +} \ No newline at end of file diff --git a/app/MetaGer.php b/app/MetaGer.php index d19783917c5c67fc787071b71a9dacd54b05770e..5581be75e8b4d930b6db68feb0ade833ffd350c6 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -78,6 +78,7 @@ class MetaGer protected $redisEngineResult; protected $redisCurrentResultList; public $starttime; + protected $dummy = false; public function __construct($hash = "") { @@ -300,7 +301,7 @@ class MetaGer if (empty($this->adgoalLoaded)) { $this->adgoalLoaded = false; } - if (!$this->apiAuthorized && !$this->adgoalLoaded) { + if (!$this->apiAuthorized && !$this->adgoalLoaded && !$this->dummy) { if (empty($this->adgoalHash)) { if (!empty($this->jskey)) { $js = Redis::connection('cache')->lpop("js" . $this->jskey); @@ -1054,9 +1055,9 @@ class MetaGer $this->fokus = $request->input('focus', 'web'); # Suma-File if (App::isLocale("en")) { - $this->sumaFile = config_path() . "/sumasEn.json"; + $this->sumaFile = config_path() . ($this->dummy ? "/stress.json" : "/sumasEn.json"); } else { - $this->sumaFile = config_path() . "/sumas.json"; + $this->sumaFile = config_path() . ($this->dummy ? "/stress.json" : "/sumas.json"); } if (!file_exists($this->sumaFile)) { die(trans('metaGer.formdata.cantLoad')); @@ -1235,8 +1236,12 @@ class MetaGer public function createQuicktips() { # Die quicktips werden als job erstellt und zur Abarbeitung freigegeben - $quicktips = new \App\Models\Quicktips\Quicktips($this->q, LaravelLocalization::getCurrentLocale(), $this->getTime(), $this->sprueche); - return $quicktips; + if(!$this->dummy) { + $quicktips = new \App\Models\Quicktips\Quicktips($this->q, LaravelLocalization::getCurrentLocale(), $this->getTime(), $this->sprueche); + return $quicktips; + }else { + return null; + } } @@ -2036,4 +2041,9 @@ class MetaGer { $this->engines = $engines; } + + public function setDummy($dummy) + { + $this->dummy = $dummy; + } } diff --git a/config/stress.json b/config/stress.json new file mode 100644 index 0000000000000000000000000000000000000000..181de977f56660ea1cd120b9eccc317df7d7c0f7 --- /dev/null +++ b/config/stress.json @@ -0,0 +1,115 @@ +{ + "sumas": { + "dummy": { + "host": "production-auto-deploy.dummy-engine-87.svc.cluster.local", + "path": "\/", + "port": 80, + "query-parameter": "q", + "input-encoding": "utf8", + "output-encoding": "utf8", + "parser-class": "Dummy", + "get-parameter": {}, + "request-header": {}, + "display-name": "dummy", + "engine-boost": 1, + "cache-duration": 0, + "disabled": false, + "filter-opt-in": false, + "homepage": "https:\/\/gitlab.metager.de\/open-source\/dummy-engine" + } + }, + "foki": { + "web": { + "display-name": "index.foki.web", + "sumas": [ + "dummy" + ], + "main": [ + "dummy" + ] + } + }, + "filter": { + "query-filter": {}, + "parameter-filter": { + "count": { + "name": "metaGer.filter.count", + "desc": "", + "get-parameter": "count", + "values": { + "10": "10", + "20": "20", + "30": "30", + "40": "40", + "50": "50", + "100": "100" + }, + "sumas": { + "dummy": { + "get-parameter": "count", + "values": { + "10": "10", + "20": "20", + "30": "30", + "40": "40", + "50": "50", + "100": "100" + } + } + } + }, + "min": { + "name": "metaGer.filter.min", + "desc": "", + "get-parameter": "min", + "values": { + "nofilter" : "0", + "2": "2", + "4": "4", + "6": "6", + "8": "8", + "10": "10" + }, + "sumas": { + "dummy": { + "get-parameter": "min", + "values": { + "nofilter" : "0", + "2": "2000", + "4": "4000", + "6": "6000", + "8": "8000", + "10": "10000" + } + } + } + }, + "max": { + "name": "metaGer.filter.max", + "desc": "", + "get-parameter": "max", + "values": { + "nofilter" : "0", + "2": "2", + "4": "4", + "6": "6", + "8": "8", + "10": "10" + }, + "sumas": { + "dummy": { + "get-parameter": "max", + "values": { + "nofilter" : "0", + "2": "2000", + "4": "4000", + "6": "6000", + "8": "8000", + "10": "10000" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 6ce056c1fcbf6dbb0f3f86e9357732411096832a..da5dae281108282da61ea83896f0d34393a1172e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -192,6 +192,8 @@ Route::group( Route::post('deleteRegexp', 'AdminSpamController@deleteRegexp'); }); Route::post('service-desk', 'ServiceDesk@webhook'); + Route::get('stress', 'Stresstest@index'); + Route::get('stress/verify', 'Stresstest@index')->middleware('browserverification', 'humanverification'); }); Route::get('settings', function () {