add test for checking service ready and health

This commit is contained in:
Viktor Scharf
2024-10-18 15:30:26 +02:00
committed by Prajwol Amatya
parent 46d397d74f
commit 18e0af90b7
7 changed files with 280 additions and 0 deletions

View File

@@ -728,6 +728,24 @@ class FeatureContext extends BehatVariablesContext {
return $parsedUrl["host"] . ":" . $parsedUrl["port"];
}
/**
* removes the port rom the ocis URL
*
* @param string $url
*
* @return string
*/
public function removePortFromUrl(string $url): string {
return \str_replace(':9200', '', $url);
}
/**
* @return string
*/
public function getOcPath(): string {
return $this->ocPath;
}
/**
* returns the base URL (which is without a slash at the end)
*
@@ -783,6 +801,15 @@ class FeatureContext extends BehatVariablesContext {
return $this->removeSchemeFromUrl($this->getBaseUrl());
}
/**
* returns the base URL but without "http(s)://" and port
*
* @return string
*/
public function getBaseUrlWithoutSchemeAndPort(): string {
return $this->removePortFromUrl($this->removeSchemeFromUrl($this->getBaseUrl()));
}
/**
* returns the local base URL (which is without a slash at the end)
*
@@ -2178,6 +2205,14 @@ class FeatureContext extends BehatVariablesContext {
],
"parameter" => []
],
[
"code" => "%base_url_without_scheme_and_port%",
"function" => [
$this,
"getBaseUrlWithoutSchemeAndPort"
],
"parameter" => []
],
[
"code" => "%remote_server%",
"function" => [
@@ -2960,4 +2995,26 @@ class FeatureContext extends BehatVariablesContext {
}
return false;
}
/**
* @When a user requests these endpoints:
*
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function userRequestsEndpoints(TableNode $table): void {
$this->verifyTableNodeColumns($table, ['endpoint'], ['service', 'comment']);
foreach ($table->getHash() as $row) {
$this->setResponse(
HttpRequestHelper::sendRequest(
$this->substituteInLineCodes($row['endpoint']),
$this->getStepLineRef()
)
);
$this->pushToLastStatusCodesArrays();
}
}
}