Skip to content

Commit

Permalink
update the scenarios for service availability check
Browse files Browse the repository at this point in the history
  • Loading branch information
PrajwolAmatya committed Nov 28, 2024
1 parent 15420a3 commit dc7bdf2
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 179 deletions.
7 changes: 4 additions & 3 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ config = {
"apiDepthInfinity",
"apiLocks",
"apiActivities",
"apiServiceAvailability",
],
"skip": False,
},
"graph": {
"suites": [
"apiGraph",
"apiServiceAvailability",
],
"skip": False,
"withRemotePhp": [True],
Expand Down Expand Up @@ -240,7 +240,6 @@ config = {
"collaborationServiceNeeded": True,
"extraServerEnvironment": {
"GATEWAY_GRPC_ADDR": "0.0.0.0:9142",
"COLLABORATION_DEBUG_ADDR": "0.0.0.0:9304",
},
},
"cliCommands": {
Expand Down Expand Up @@ -1033,6 +1032,7 @@ def localApiTests(ctx, name, suites, storage = "ocis", extra_environment = {}, w
"UPLOAD_DELETE_WAIT_TIME": "1" if storage == "owncloud" else 0,
"OCIS_WRAPPER_URL": "http://%s:5200" % OCIS_SERVER_NAME,
"WITH_REMOTE_PHP": with_remote_php,
"COLLABORATION_SERVICE_URL": "http://wopi-fakeoffice:9300",
}

for item in extra_environment:
Expand Down Expand Up @@ -2341,6 +2341,7 @@ def ocisServer(storage = "ocis", accounts_hash_difficulty = 4, volumes = [], dep
"GROUPS_DEBUG_ADDR": "0.0.0.0:9161",
"IDM_DEBUG_ADDR": "0.0.0.0:9239",
"IDP_DEBUG_ADDR": "0.0.0.0:9134",
"INVITATIONS_DEBUG_ADDR": "0.0.0.0:9269",
"NATS_DEBUG_ADDR": "0.0.0.0:9234",
"OCDAV_DEBUG_ADDR": "0.0.0.0:9163",
"OCM_DEBUG_ADDR": "0.0.0.0:9281",
Expand All @@ -2360,6 +2361,7 @@ def ocisServer(storage = "ocis", accounts_hash_difficulty = 4, volumes = [], dep
"USERS_DEBUG_ADDR": "0.0.0.0:9145",
"WEB_DEBUG_ADDR": "0.0.0.0:9104",
"WEBDAV_DEBUG_ADDR": "0.0.0.0:9119",
"WEBFINGER_DEBUG_ADDR": "0.0.0.0:9279",
}

if deploy_type == "":
Expand Down Expand Up @@ -3151,7 +3153,6 @@ def wopiCollaborationService(name):
"COLLABORATION_CS3API_DATAGATEWAY_INSECURE": "true",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"COLLABORATION_WOPI_SECRET": "some-wopi-secret",
"OCIS_ADD_RUN_SERVICES": "collaboration",
}

if name == "collabora":
Expand Down
10 changes: 10 additions & 0 deletions tests/acceptance/TestHelpers/OcisHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ public static function getFederatedServerUrl(): string {
return 'https://localhost:10200';
}

/**
* @return string
*/
public static function getCollaborationServiceUrl(): string {
if (\getenv("COLLABORATION_SERVICE_URL")) {
return \getenv("COLLABORATION_SERVICE_URL");
}
return "http://localhost:9300";
}

/**
* @return bool
*/
Expand Down
9 changes: 7 additions & 2 deletions tests/acceptance/bootstrap/AuthContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,14 @@ public function userRequestsEndpointsWithoutBodyAndNoAuthAboutUser(string $metho
* @throws Exception
*/
public function userRequestsEndpointsWithNoAuthentication(string $method, TableNode $table):void {
$this->featureContext->verifyTableNodeColumns($table, ['endpoint']);
$this->featureContext->verifyTableNodeColumns($table, ['endpoint'], ['service']);
foreach ($table->getHash() as $row) {
$this->featureContext->setResponse($this->sendRequest($row['endpoint'], $method));
$this->featureContext->setResponse(
$this->sendRequest(
$this->featureContext->substituteInLineCodes($row['endpoint']),
$method
)
);
$this->featureContext->pushToLastStatusCodesArrays();
}
}
Expand Down
59 changes: 24 additions & 35 deletions tests/acceptance/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,15 +735,9 @@ public function removeSchemeFromUrl(string $url): string {
*
* @return string
*/
public function removePortFromUrl(string $url): string {
return \str_replace(':9200', '', $url);
}

/**
* @return string
*/
public function getOcPath(): string {
return $this->ocPath;
public function removeSchemeAndPortFromUrl(string $url): string {
$parsedUrl = parse_url($url);
return $parsedUrl["host"];
}

/**
Expand Down Expand Up @@ -806,8 +800,17 @@ public function getBaseUrlWithoutScheme(): string {
*
* @return string
*/
public function getBaseUrlWithoutSchemeAndPort(): string {
return $this->removePortFromUrl($this->removeSchemeFromUrl($this->getBaseUrl()));
public function getBaseUrlHostName(): string {
return $this->removeSchemeAndPortFromUrl($this->getBaseUrl());
}

/**
* returns the base URL but without "http(s)://" and port
*
* @return string
*/
public function getCollaborationHostName(): string {
return $this->removeSchemeAndPortFromUrl(OcisHelper::getCollaborationServiceUrl());
}

/**
Expand Down Expand Up @@ -2206,10 +2209,18 @@ public function substituteInLineCodes(
"parameter" => []
],
[
"code" => "%base_url_without_scheme_and_port%",
"code" => "%base_url_hostname%",
"function" => [
$this,
"getBaseUrlHostName"
],
"parameter" => []
],
[
"code" => "%collaboration_hostname%",
"function" => [
$this,
"getBaseUrlWithoutSchemeAndPort"
"getCollaborationHostName"
],
"parameter" => []
],
Expand Down Expand Up @@ -2995,26 +3006,4 @@ public static function isExpectedToFail(string $scenarioLine): bool {
}
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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Feature: service health check


Scenario: check service health
When a user requests these endpoints:
| endpoint | service |
| %base_url_without_scheme_and_port%:9297/healthz | antivirus |
When a user requests these endpoints with "GET" and no authentication
| endpoint | service |
| %base_url_hostname%:9297/healthz | antivirus |
Then the HTTP status code of responses on all endpoints should be "200"


Scenario: check service readiness
When a user requests these endpoints:
| endpoint | service |
| %base_url_without_scheme_and_port%:9297/readyz | antivirus |
When a user requests these endpoints with "GET" and no authentication
| endpoint | service |
| %base_url_hostname%:9297/readyz | antivirus |
Then the HTTP status code of responses on all endpoints should be "200"
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
Feature: service health check

@skip

Scenario: check service health
When a user requests these endpoints:
| endpoint | service | comment |
| wopi-onlyoffice:9304/healthz | collaboration | wopi-onlyoffice port 9304: Connection refused in CI |
| wopi-collabora:9304/healthz | collaboration | wopi-collabora port 9304: Connection refused in CI |
| wopi-fakeoffice:9304/healthz | collaboration | wopi-fakeoffice port 9304: Connection refused in CI |
When a user requests these endpoints with "GET" and no authentication
| endpoint | service | comment |
| %collaboration_hostname%:9304/healthz | collaboration | |
Then the HTTP status code of responses on all endpoints should be "200"

@skip

Scenario: check service readiness
When a user requests these endpoints:
| endpoint | service | comment |
| wopi-onlyoffice:9304/readyz | collaboration | wopi-onlyoffice port 9304: Connection refused in CI |
| wopi-collabora:9304/readyz | collaboration | wopi-collabora port 9304: Connection refused in CI |
| wopi-fakeoffice:9304/readyz | collaboration | wopi-fakeoffice port 9304: Connection refused in CI |
Then the HTTP status code of responses on all endpoints should be "200"
When a user requests these endpoints with "GET" and no authentication
| endpoint | service | comment |
| %collaboration_hostname%:9304/readyz | collaboration | |
Then the HTTP status code of responses on all endpoints should be "200"
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Feature: service health check


Scenario: check service health
When a user requests these endpoints:
| endpoint | service |
| %base_url_without_scheme_and_port%:9174/healthz | notification |
When a user requests these endpoints with "GET" and no authentication
| endpoint | service |
| %base_url_hostname%:9174/healthz | notification |
Then the HTTP status code of responses on all endpoints should be "200"


Scenario: check service readiness
When a user requests these endpoints:
| endpoint | service |
| %base_url_without_scheme_and_port%:9174/readyz | notification |
When a user requests these endpoints with "GET" and no authentication
| endpoint | service |
| %base_url_hostname%:9174/readyz | notification |
Then the HTTP status code of responses on all endpoints should be "200"
Loading

0 comments on commit dc7bdf2

Please sign in to comment.