Skip to content

Commit ca9b9a4

Browse files
review addressed
1 parent 945d121 commit ca9b9a4

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

tests/ociswrapper/README.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,26 @@ Also, see `./bin/ociswrapper help` for more information.
125125
- `200 OK` - oCIS server is stopped
126126
- `500 Internal Server Error` - Unable to stop oCIS server
127127

128-
6. `POST /services/{service-name}`
128+
6. `POST /services/{service-name}`
129129

130-
Restart oCIS with service excluded and start excluded oCIS service individually, not covered by the oCIS supervisor.
130+
Restart oCIS with service excluded and start excluded oCIS service individually, not covered by the oCIS supervisor.
131131

132-
Body of the request should be a JSON object with the following structure:
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+
```
133140

134-
```json
135-
{
136-
"ENV_KEY1": "value1",
137-
"ENV_KEY2": "value2"
138-
}
139-
```
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+
> `{SERVICE-NAME}_HTTP_ADDR=0.0.0.0:{HTTP_PORT}`
140147

141-
> **⚠️ WARNING:**
142-
> You need to set the address of the debug server to expose the port in CI
143-
> `{SERVICE-NAME}_DEBUG_ADDR`
144148

145149
Returns:
146150

tests/ociswrapper/ocis/config/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ func Get(key string) string {
5959
return config[key]
6060
}
6161

62-
func SetService(key string, value int) {
62+
func SetServiceDebugPort(key string, value int) {
6363
services[key] = value
6464
}
6565

66-
func GetService(key string) int {
66+
func GetServiceDebugPort(key string) int {
6767
return services[key]
6868
}

tests/ociswrapper/ocis/ocis.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var EnvConfigs = []string{}
3030
var runningServices = make(map[string]int)
3131

3232
func Start(envMap []string) {
33-
log.Println("Starting oCIS service........")
33+
log.Println("Starting oCIS service...")
3434
StartService("", envMap)
3535
}
3636

@@ -328,13 +328,13 @@ func StopService(service string) (bool, string) {
328328
return true, fmt.Sprintf("Service %s stopped successfully", service)
329329
}
330330

331-
// WaitUntilPortListens waits until the port for a given service is listening
332-
func WaitUntilPortListens(service string) bool {
331+
// wait until the port for a given service is listening
332+
func WaitForService(service string) bool {
333333
overallTimeout := time.After(30 * time.Second)
334334
ticker := time.NewTicker(2 * time.Second)
335335
defer ticker.Stop()
336336

337-
port := config.GetService(service)
337+
port := config.GetServiceDebugPort(service)
338338

339339
for {
340340
select {
@@ -349,7 +349,6 @@ func WaitUntilPortListens(service string) bool {
349349
continue
350350
}
351351

352-
// Check if the port is listening
353352
address := fmt.Sprintf(":%d", port)
354353
// Try to connect to the port
355354
conn, err := net.DialTimeout("tcp", address, 1*time.Second)
@@ -358,7 +357,7 @@ func WaitUntilPortListens(service string) bool {
358357
log.Println(fmt.Sprintf("%s service is ready to listen port %d", service, port))
359358
return true
360359
}
361-
log.Println(fmt.Sprintf("%v port is not ready %v\n", conn, err))
360+
log.Println(fmt.Sprintf("%s service is not ready on port %v. %v\n", service, port, err))
362361
}
363362
}
364363
}

tests/ociswrapper/wrapper/handlers/handler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func OcisServiceHandler(res http.ResponseWriter, req *http.Request) {
231231
if strings.HasSuffix(key, "DEBUG_ADDR") {
232232
address := strings.Split(value.(string), ":")
233233
port, _ := strconv.Atoi(address[1])
234-
config.SetService(serviceName, port)
234+
config.SetServiceDebugPort(serviceName, port)
235235
}
236236
}
237237

@@ -240,7 +240,7 @@ func OcisServiceHandler(res http.ResponseWriter, req *http.Request) {
240240
common.Wg.Add(1)
241241
go ocis.StartService(serviceName, serviceEnvMap)
242242

243-
success := ocis.WaitUntilPortListens(serviceName)
243+
success := ocis.WaitForService(serviceName)
244244
if success {
245245
log.Println(fmt.Sprintf("Found Port for %s......", serviceName))
246246
sendResponse(res, http.StatusOK, fmt.Sprintf("oCIS service %s started successfully", serviceName))

0 commit comments

Comments
 (0)