Skip to content

Commit ed8346b

Browse files
add support service start and stop
1 parent ac1689b commit ed8346b

File tree

9 files changed

+427
-115
lines changed

9 files changed

+427
-115
lines changed

tests/acceptance/TestHelpers/OcisConfigHelper.php

+16
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,20 @@ public static function startOcis(): ResponseInterface {
120120
$url = self::getWrapperUrl() . "/start";
121121
return self::sendRequest($url, "POST");
122122
}
123+
124+
/**
125+
* this method stops the running oCIS instance,
126+
* restarts oCIS without specific services,
127+
* and then starts the excluded services separately.
128+
*
129+
* @param string $service
130+
* @param array $envs
131+
*
132+
* @return ResponseInterface
133+
* @throws GuzzleException
134+
*/
135+
public static function startService(string $service, array $envs = []): ResponseInterface {
136+
$url = self::getWrapperUrl() . "/services/" . $service;
137+
return self::sendRequest($url, "POST", \json_encode($envs));
138+
}
123139
}

tests/acceptance/bootstrap/OcisConfigContext.php

+26
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,32 @@ public function theConfigHasBeenSetToValue(TableNode $table): void {
191191
);
192192
}
193193

194+
/**
195+
* @Given the administrator has started service :service separately with the following configs:
196+
*
197+
* @param string $service
198+
* @param TableNode $table
199+
*
200+
* @return void
201+
* @throws GuzzleException
202+
*/
203+
public function theAdministratorHasStartedServiceSeparatelyWithTheFollowingConfig(
204+
string $service,
205+
TableNode $table
206+
): void {
207+
$envs = [];
208+
foreach ($table->getHash() as $row) {
209+
$envs[$row['config']] = $row['value'];
210+
}
211+
212+
$response = OcisConfigHelper::startService($service, $envs);
213+
Assert::assertEquals(
214+
200,
215+
$response->getStatusCode(),
216+
"Failed to start service $service."
217+
);
218+
}
219+
194220
/**
195221
* @AfterScenario @env-config
196222
*

tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ The expected failures in this file are from features in the owncloud/ocis repo.
321321
- [apiSharingNg1/propfindShares.feature:149](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg1/propfindShares.feature#L149)
322322

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

327328
Note: always have an empty line at the end of this file.
328329
The bash script that processes this file requires that the last line has a newline on the end.

tests/acceptance/features/apiServiceAvailability/serviceAvailabilityCheck.feature

+35-17
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ Feature: service health check
4343
@env-config
4444
Scenario: check extra services health
4545
Given the following configs have been set:
46-
| config | value |
47-
| OCIS_ADD_RUN_SERVICES | audit,auth-app,auth-bearer,policies,invitations |
48-
| AUDIT_DEBUG_ADDR | 0.0.0.0:9229 |
49-
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
50-
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
51-
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
46+
| config | value |
47+
| OCIS_ADD_RUN_SERVICES | auth-app,policies,invitations |
48+
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
49+
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
50+
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
5251
When a user requests these URLs with "GET" and no authentication
5352
| endpoint | service |
54-
| http://%base_url_hostname%:9229/healthz | audit |
5553
| http://%base_url_hostname%:9245/healthz | auth-app |
5654
| http://%base_url_hostname%:9269/healthz | invitations |
5755
| http://%base_url_hostname%:9129/healthz | policies |
@@ -97,23 +95,20 @@ Feature: service health check
9795
@env-config
9896
Scenario: check extra services readiness
9997
Given the following configs have been set:
100-
| config | value |
101-
| OCIS_ADD_RUN_SERVICES | audit,auth-app,auth-bearer,policies,invitations |
102-
| AUDIT_DEBUG_ADDR | 0.0.0.0:9229 |
103-
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
104-
| AUTH_BEARER_DEBUG_ADDR | 0.0.0.0:9149 |
105-
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
106-
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
98+
| config | value |
99+
| OCIS_ADD_RUN_SERVICES | auth-app,policies,invitations |
100+
| AUTH_APP_DEBUG_ADDR | 0.0.0.0:9245 |
101+
| POLICIES_DEBUG_ADDR | 0.0.0.0:9129 |
102+
| INVITATIONS_DEBUG_ADDR | 0.0.0.0:9269 |
107103
When a user requests these URLs with "GET" and no authentication
108104
| endpoint | service |
109-
| http://%base_url_hostname%:9229/readyz | audit |
110105
| http://%base_url_hostname%:9245/readyz | auth-app |
111106
| http://%base_url_hostname%:9269/readyz | invitations |
112107
| http://%base_url_hostname%:9129/readyz | policies |
113108
Then the HTTP status code of responses on all endpoints should be "200"
114109

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

124119
@env-config @issue-10661
125-
Scenario: check extra services readiness
120+
Scenario: check auth-bearer service health
121+
Given the following configs have been set:
122+
| config | value |
123+
| OCIS_ADD_RUN_SERVICES | auth-bearer |
124+
| AUTH_BEARER_DEBUG_ADDR | 0.0.0.0:9149 |
125+
When a user requests these URLs with "GET" and no authentication
126+
| endpoint | service |
127+
| http://%base_url_hostname%:9149/healthz | auth-bearer |
128+
Then the HTTP status code should be "200"
129+
130+
@env-config @issue-10661
131+
Scenario: check auth-bearer service readiness
126132
Given the following configs have been set:
127133
| config | value |
128134
| OCIS_ADD_RUN_SERVICES | auth-bearer |
129135
| AUTH_BEARER_DEBUG_ADDR | 0.0.0.0:9149 |
130136
When a user requests these URLs with "GET" and no authentication
131137
| endpoint | service |
132138
| http://%base_url_hostname%:9149/readyz | auth-bearer |
139+
Then the HTTP status code should be "200"
140+
141+
@env-config
142+
Scenario: check services health and readiness while running separately
143+
Given the administrator has started service "audit" separately with the following configs:
144+
| config | value |
145+
| OCIS_LOG_LEVEL | info |
146+
| AUDIT_DEBUG_ADDR | 0.0.0.0:9229 |
147+
When a user requests these URLs with "GET" and no authentication
148+
| endpoint | service |
149+
| http://%base_url_hostname%:9229/healthz | audit |
150+
| http://%base_url_hostname%:9229/readyz | audit |
133151
Then the HTTP status code of responses on all endpoints should be "200"

tests/ociswrapper/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,39 @@ Also, see `./bin/ociswrapper help` for more information.
124124

125125
- `200 OK` - oCIS server is stopped
126126
- `500 Internal Server Error` - Unable to stop oCIS server
127+
128+
6. `POST /services/{service-name}`
129+
130+
Restart oCIS instances without specified service and start that service independently (not covered by the oCIS supervisor).
131+
132+
Body of the request should be a JSON object with the following structure:
133+
134+
```json
135+
{
136+
"ENV_KEY1": "value1",
137+
"ENV_KEY2": "value2"
138+
}
139+
```
140+
141+
> **⚠️ Note:**
142+
>
143+
> You need to set the proper addresses to access the service from other steps in the CI pipeline.
144+
>
145+
> `{SERVICE-NAME}_DEBUG_ADDR=0.0.0.0:{DEBUG_PORT}`
146+
>
147+
> `{SERVICE-NAME}_HTTP_ADDR=0.0.0.0:{HTTP_PORT}`
148+
149+
Returns:
150+
151+
- `200 OK` - oCIS service started successfully
152+
- `400 Bad Request` - request body is not a valid JSON object
153+
- `500 Internal Server Error` - Failed to start oCIS service audit
154+
155+
7. `DELETE /services/{service-name}`
156+
157+
Stop individually running oCIS service
158+
159+
Returns:
160+
161+
- `200 OK` - oCIS service stopped successfully
162+
- `500 Internal Server Error` - Unable to stop oCIS service

tests/ociswrapper/ocis/config/config.go

+51
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,61 @@ var config = map[string]string{
88
"adminPassword": "",
99
}
1010

11+
var services = map[string]int{
12+
"ocis": 9250,
13+
"activitylog": 9197,
14+
"app-provider": 9165,
15+
"app-registry": 9243,
16+
"audit": 9149,
17+
"auth-app": 9245,
18+
"auth-bearer": 9149,
19+
"auth-basic": 9147,
20+
"auth-machine": 9167,
21+
"auth-service": 9198,
22+
"clientlog": 9260,
23+
"eventhistory": 9270,
24+
"frontend": 9141,
25+
"gateway": 9143,
26+
"graph": 9124,
27+
"groups": 9161,
28+
"idm": 9239,
29+
"idp": 9134,
30+
"invitations": 9269,
31+
"nats": 9234,
32+
"ocdav": 9163,
33+
"ocm": 9281,
34+
"ocs": 9114,
35+
"policies": 9129,
36+
"postprocessing": 9255,
37+
"proxy": 9205,
38+
"search": 9224,
39+
"settings": 9194,
40+
"sharing": 9151,
41+
"sse": 9139,
42+
"storage-publiclink": 9179,
43+
"storage-shares": 9156,
44+
"storage-system": 9217,
45+
"storage-users": 9159,
46+
"thumbnails": 9189,
47+
"userlog": 9214,
48+
"users": 9145,
49+
"web": 9104,
50+
"webdav": 9119,
51+
"webfinger": 9279,
52+
}
53+
1154
func Set(key string, value string) {
1255
config[key] = value
1356
}
1457

1558
func Get(key string) string {
1659
return config[key]
1760
}
61+
62+
func SetServiceDebugPort(key string, value int) {
63+
services[key] = value
64+
}
65+
66+
func GetServiceDebugPort(key string) int {
67+
return services[key]
68+
}

0 commit comments

Comments
 (0)