Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[full-ci][tests-only]Add support to stop and start service in ociswrapper #10776

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/acceptance/TestHelpers/OcisConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,20 @@ public static function startOcis(): ResponseInterface {
$url = self::getWrapperUrl() . "/start";
return self::sendRequest($url, "POST");
}

/**
* this method stops the running oCIS instance,
* restarts oCIS without specific services,
* and then starts the excluded services separately.
*
* @param string $service
* @param array $envs
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function startService(string $service, array $envs = []): ResponseInterface {
$url = self::getWrapperUrl() . "/services/" . $service;
return self::sendRequest($url, "POST", \json_encode($envs));
}
}
26 changes: 26 additions & 0 deletions tests/acceptance/bootstrap/OcisConfigContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,32 @@ public function theConfigHasBeenSetToValue(TableNode $table): void {
);
}

/**
* @Given the administrator has started service :service separately with the following configs:
*
* @param string $service
* @param TableNode $table
*
* @return void
* @throws GuzzleException
*/
public function theAdministratorHasStartedServiceSeparatelyWithTheFollowingConfig(
string $service,
TableNode $table
): void {
$envs = [];
foreach ($table->getHash() as $row) {
$envs[$row['config']] = $row['value'];
}

$response = OcisConfigHelper::startService($service, $envs);
Assert::assertEquals(
200,
$response->getStatusCode(),
"Failed to start service $service."
);
}

/**
* @AfterScenario @env-config
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSharingNg1/propfindShares.feature:149](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg1/propfindShares.feature#L149)

#### [Readiness check for some services returns 500 status code](https://github.com/owncloud/ocis/issues/10661)
- [apiServiceAvailability/serviceAvailabilityCheck.feature:116](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L116)
- [apiServiceAvailability/serviceAvailabilityCheck.feature:125](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L125)
- [apiServiceAvailability/serviceAvailabilityCheck.feature:111](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L111)
- [apiServiceAvailability/serviceAvailabilityCheck.feature:120](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L120)
- [apiServiceAvailability/serviceAvailabilityCheck.feature:131](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature#L131)

Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ Feature: service health check
@env-config
Scenario: check extra services health
Given the following configs have been set:
| config | value |
| OCIS_ADD_RUN_SERVICES | audit,auth-app,auth-bearer,policies,invitations |
| AUDIT_DEBUG_ADDR | 0.0.0.0:9229 |
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
| config | value |
| OCIS_ADD_RUN_SERVICES | auth-app,policies,invitations |
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
When a user requests these URLs with "GET" and no authentication
| endpoint | service |
| http://%base_url_hostname%:9229/healthz | audit |
| http://%base_url_hostname%:9245/healthz | auth-app |
| http://%base_url_hostname%:9269/healthz | invitations |
| http://%base_url_hostname%:9129/healthz | policies |
Expand Down Expand Up @@ -97,23 +95,20 @@ Feature: service health check
@env-config
Scenario: check extra services readiness
Given the following configs have been set:
| config | value |
| OCIS_ADD_RUN_SERVICES | audit,auth-app,auth-bearer,policies,invitations |
| AUDIT_DEBUG_ADDR | 0.0.0.0:9229 |
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
| AUTH_BEARER_DEBUG_ADDR | 0.0.0.0:9149 |
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
| config | value |
| OCIS_ADD_RUN_SERVICES | auth-app,policies,invitations |
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
When a user requests these URLs with "GET" and no authentication
| endpoint | service |
| http://%base_url_hostname%:9229/readyz | audit |
| http://%base_url_hostname%:9245/readyz | auth-app |
| http://%base_url_hostname%:9269/readyz | invitations |
| http://%base_url_hostname%:9129/readyz | policies |
Then the HTTP status code of responses on all endpoints should be "200"

@issue-10661
Scenario: check default services readiness
Scenario: check default services readiness (graph, idp, proxy)
When a user requests these URLs with "GET" and no authentication
| endpoint | service |
| http://%base_url_hostname%:9124/readyz | graph |
Expand All @@ -122,12 +117,35 @@ Feature: service health check
Then the HTTP status code of responses on all endpoints should be "200"

@env-config @issue-10661
Scenario: check extra services readiness
Scenario: check auth-bearer service health
Given the following configs have been set:
| config | value |
| OCIS_ADD_RUN_SERVICES | auth-bearer |
| AUTH_BEARER_DEBUG_ADDR | 0.0.0.0:9149 |
When a user requests these URLs with "GET" and no authentication
| endpoint | service |
| http://%base_url_hostname%:9149/healthz | auth-bearer |
Then the HTTP status code should be "200"

@env-config @issue-10661
Scenario: check auth-bearer service readiness
Given the following configs have been set:
| config | value |
| OCIS_ADD_RUN_SERVICES | auth-bearer |
| AUTH_BEARER_DEBUG_ADDR | 0.0.0.0:9149 |
When a user requests these URLs with "GET" and no authentication
| endpoint | service |
| http://%base_url_hostname%:9149/readyz | auth-bearer |
Then the HTTP status code should be "200"

@env-config
Scenario: check services health and readiness while running separately
Given the administrator has started service "audit" separately with the following configs:
| config | value |
| OCIS_LOG_LEVEL | info |
| AUDIT_DEBUG_ADDR | 0.0.0.0:9229 |
When a user requests these URLs with "GET" and no authentication
| endpoint | service |
| http://%base_url_hostname%:9229/healthz | audit |
| http://%base_url_hostname%:9229/readyz | audit |
Then the HTTP status code of responses on all endpoints should be "200"
36 changes: 36 additions & 0 deletions tests/ociswrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,39 @@ Also, see `./bin/ociswrapper help` for more information.

- `200 OK` - oCIS server is stopped
- `500 Internal Server Error` - Unable to stop oCIS server

6. `POST /services/{service-name}`

Restart oCIS instances without specified service and start that service independently (not covered by the oCIS supervisor).

Body of the request should be a JSON object with the following structure:

```json
{
"ENV_KEY1": "value1",
"ENV_KEY2": "value2"
}
```

> **⚠️ Note:**
>
> You need to set the proper addresses to access the service from other steps in the CI pipeline.
>
> `{SERVICE-NAME}_DEBUG_ADDR=0.0.0.0:{DEBUG_PORT}`
>
> `{SERVICE-NAME}_HTTP_ADDR=0.0.0.0:{HTTP_PORT}`

Returns:

- `200 OK` - oCIS service started successfully
- `400 Bad Request` - request body is not a valid JSON object
- `500 Internal Server Error` - Failed to start oCIS service audit

7. `DELETE /services/{service-name}`

Stop individually running oCIS service

Returns:

- `200 OK` - oCIS service stopped successfully
- `500 Internal Server Error` - Unable to stop oCIS service
51 changes: 51 additions & 0 deletions tests/ociswrapper/ocis/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,61 @@ var config = map[string]string{
"adminPassword": "",
}

var services = map[string]int{
"ocis": 9250,
"activitylog": 9197,
"app-provider": 9165,
"app-registry": 9243,
"audit": 9149,
"auth-app": 9245,
"auth-bearer": 9149,
"auth-basic": 9147,
"auth-machine": 9167,
"auth-service": 9198,
"clientlog": 9260,
"eventhistory": 9270,
"frontend": 9141,
"gateway": 9143,
"graph": 9124,
"groups": 9161,
"idm": 9239,
"idp": 9134,
"invitations": 9269,
"nats": 9234,
"ocdav": 9163,
"ocm": 9281,
"ocs": 9114,
"policies": 9129,
"postprocessing": 9255,
"proxy": 9205,
"search": 9224,
"settings": 9194,
"sharing": 9151,
"sse": 9139,
"storage-publiclink": 9179,
"storage-shares": 9156,
"storage-system": 9217,
"storage-users": 9159,
"thumbnails": 9189,
"userlog": 9214,
"users": 9145,
"web": 9104,
"webdav": 9119,
"webfinger": 9279,
}

func Set(key string, value string) {
config[key] = value
}

func Get(key string) string {
return config[key]
}

func SetServiceDebugPort(key string, value int) {
services[key] = value
}

func GetServiceDebugPort(key string) int {
return services[key]
}
Loading