Skip to content

Commit ae5adb8

Browse files
authored
feat: Testing cluster: EPPO_BASE_URL environment variable (#77)
* remove php relay after running * plumb through EPPO_BASE_URL as a combination of host and port
1 parent a98236c commit ae5adb8

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

package-testing/php-sdk-relay/.env.EXAMPLE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Set your appropriate values and save as `.env`
2-
EPPO_API_HOST=localhost
3-
EPPO_API_PORT=5000
2+
EPPO_BASE_URL=localhost:5000
43
EPPO_API_KEY=A123456780
54

65
SDK_RELAY_HOST=localhost

package-testing/php-sdk-relay/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ COPY --chmod=755 build-and-run.sh /
2222
RUN composer install
2323

2424
ENV SDK_RELAY_HOST=0.0.0.0
25-
ENV EPPO_API_HOST=host.docker.internal
2625

2726
EXPOSE $SDK_RELAY_PORT
2827

package-testing/php-sdk-relay/docker-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ docker run -p $SDK_RELAY_PORT:$SDK_RELAY_PORT \
1313
-e SDK_REF \
1414
-e SDK_RELAY_PORT \
1515
--name php-relay \
16-
-d \
16+
-d --rm \
1717
-t Eppo-exp/php-sdk-relay:$VERSION && \
1818
echo "Container running"

package-testing/php-sdk-relay/src/Config.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ class Config
1010
public function __construct()
1111
{
1212
$this->apiKey = $_ENV["EPPO_API_KEY"] ?? "NOKEYSPECIFIED";
13-
$apiHost = $_ENV["EPPO_API_HOST"] ?? "localhost";
14-
$apiPort = $_ENV["EPPO_API_PORT"] ?? "5000";
15-
$this->apiServer = "http://${apiHost}:${apiPort}";
13+
$apiServer = $_ENV["EPPO_BASE_URL"] ?? "localhost:5000";
14+
$this->apiServer = "http://${apiServer}";
1615
}
1716
}

package-testing/sdk-test-runner/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,13 @@ The test runner sends assignment and bandit action requests to the SDK Relay Ser
183183

184184
#### Configuration
185185

186-
| Variable Name | Type | Description | Default |
187-
| ---------------- | ------ | ------------------------- | ----------- |
188-
| `SDK_RELAY_HOST` | string | Hostname for relay server | `localhost` |
189-
| `SDK_RELAY_PORT` | number | Port for relay server | 4000 |
190-
| `EPPO_API_HOST` | string | Hostname for api server | `localhost` |
191-
| `EPPO_API_PORT` | number | Port for api server | 5000 |
186+
| Variable Name | Type | Default | Description |
187+
| ---------------- | ------ | ---------------- | ----------------------------------------------------------------------- |
188+
| `SDK_RELAY_HOST` | string | `localhost` | Hostname for relay server |
189+
| `SDK_RELAY_PORT` | number | 4000 | Port for relay server |
190+
| `EPPO_BASE_URL` | string | `localhost:5000` | Base URL for api server, built from `EPPO_API_HOST` and `EPPO_API_PORT` |
191+
| `EPPO_API_HOST` | string | `localhost` | Hostname for api server |
192+
| `EPPO_API_PORT` | number | 5000 | Port for api server |
192193

193194
#### API
194195

package-testing/sdk-test-runner/test-sdk.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ fi
6363
# Allow env variables to be overwritten, then export to this shell.
6464
export EPPO_API_HOST="${EPPO_API_HOST:-localhost}"
6565
export EPPO_API_PORT="${EPPO_API_PORT:-5000}"
66+
export EPPO_BASE_URL="${EPPO_API_HOST}:${EPPO_API_PORT}"
6667

6768
export SDK_RELAY_HOST="${SDK_RELAY_HOST:-localhost}"
6869
export SDK_RELAY_PORT="${SDK_RELAY_PORT:-4000}"
@@ -137,7 +138,9 @@ case "$command" in
137138
BUILD_AND_RUN_PLATFORM=build-and-run-${EPPO_SDK_PLATFORM}.sh
138139
if [ -f docker-run.sh ]; then
139140
echo " ... Starting SDK Relay via docker launch script"
140-
./docker-run.sh >> ${RUNNER_DIR}/logs/sdk.log 2>&1 &
141+
142+
# Docker containers need to point at host.docker.internal instead of localhost
143+
EPPO_BASE_URL=host.docker.internal:${EPPO_API_PORT} EPPO_API_HOST=host.docker.internal ./docker-run.sh >> ${RUNNER_DIR}/logs/sdk.log 2>&1 &
141144
elif [ -f ${BUILD_AND_RUN_PLATFORM} ]; then
142145
echo " ... Starting SDK Relay via platform build-and-run script"
143146
./${BUILD_AND_RUN_PLATFORM} >> ${RUNNER_DIR}/logs/sdk.log 2>&1 &

0 commit comments

Comments
 (0)