Skip to content
Snippets Groups Projects
Commit e9c1aeda authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '1072-add-stress-test' into 'development'

Resolve "add stress test"

Closes #1072

See merge request !1769
parents 4447272a 75ac1af3
No related branches found
No related tags found
3 merge requests!1895Development,!1775Development,!1769Resolve "add stress test"
......@@ -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" => [
......
<?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
......@@ -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;
}
}
{
"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
......@@ -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 () {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment