Skip to content

Commit bf4fee5

Browse files
committed
Merge branch 'feature/PI-560-fix_proxygen_urls' into release/2024-10-22
2 parents dd04ef3 + 7b82541 commit bf4fee5

File tree

8 files changed

+74
-29
lines changed

8 files changed

+74
-29
lines changed

.github/workflows/_deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
- uses: ./.github/actions/make/
132132
if: ${{ env.SCOPE == 'per_workspace'}}
133133
with:
134-
command: apigee--deploy
134+
command: apigee--deploy PERSISTENT_ENVIRONMENT_BUILD="true"
135135
requires-aws: true
136136
restore-from-cache: "true"
137137
cache-suffix: ${{ env.CACHE_NAME }}

.github/workflows/pull-requests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
ref: ${{ env.BRANCH_NAME }}
189189
- uses: ./.github/actions/make/
190190
with:
191-
command: apigee--deploy
191+
command: apigee--deploy DEV_BUILD="true"
192192
save-to-cache: "false"
193193
restore-from-cache: "true"
194194
requires-aws: true
@@ -204,7 +204,7 @@ jobs:
204204
poetry add pytest-nhsd-apim
205205
- uses: ./.github/actions/make/
206206
with:
207-
command: apigee--attach-product
207+
command: apigee--attach-product DEV_BUILD="true"
208208
save-to-cache: "false"
209209
restore-from-cache: "true"
210210
requires-aws: true
@@ -286,7 +286,7 @@ jobs:
286286
poetry add pytest-nhsd-apim
287287
- uses: ./.github/actions/make/
288288
with:
289-
command: apigee--detach-product
289+
command: apigee--detach-product DEV_BUILD="true"
290290
save-to-cache: "false"
291291
restore-from-cache: "true"
292292
requires-aws: true
@@ -301,7 +301,7 @@ jobs:
301301
ref: ${{ env.BRANCH_NAME }}
302302
- uses: ./.github/actions/make/
303303
with:
304-
command: apigee--delete
304+
command: apigee--delete DEV_BUILD="true"
305305
save-to-cache: "false"
306306
restore-from-cache: "true"
307307
requires-aws: true

scripts/infrastructure/apigee.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ apigee--delete: aws--login
2121
AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
2222
AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
2323
AWS_SESSION_TOKEN=$(AWS_SESSION_TOKEN) \
24-
bash $(PATH_TO_INFRASTRUCTURE)/apigee/proxygen.sh delete_proxy
24+
bash $(PATH_TO_INFRASTRUCTURE)/apigee/proxygen.sh delete_proxy $(PERSISTENT_ENVIRONMENT_BUILD)
2525

2626
apigee--clean:
2727
[[ -f $(PROXYGEN_TIMESTAMP) ]] && rm $(PROXYGEN_TIMESTAMP) || :
@@ -34,7 +34,7 @@ apigee--attach-product: aws--login
3434
AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
3535
AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
3636
AWS_SESSION_TOKEN=$(AWS_SESSION_TOKEN) \
37-
bash $(PATH_TO_INFRASTRUCTURE)/apigee/apigee.sh attach_product
37+
bash $(PATH_TO_INFRASTRUCTURE)/apigee/apigee.sh attach_product $(PERSISTENT_ENVIRONMENT_BUILD)
3838

3939
apigee--detach-product: aws--login
4040
WORKSPACE_OUTPUT_JSON=$(WORKSPACE_OUTPUT_JSON) \
@@ -44,7 +44,7 @@ apigee--detach-product: aws--login
4444
AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
4545
AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
4646
AWS_SESSION_TOKEN=$(AWS_SESSION_TOKEN) \
47-
bash $(PATH_TO_INFRASTRUCTURE)/apigee/apigee.sh detach_product
47+
bash $(PATH_TO_INFRASTRUCTURE)/apigee/apigee.sh detach_product $(PERSISTENT_ENVIRONMENT_BUILD)
4848

4949
$(PROXYGEN_TIMESTAMP): aws--login $(SWAGGER_APIGEE) $(WORKSPACE_OUTPUT_JSON)
5050
[[ -f $(PROXYGEN_TIMESTAMP) ]] && rm $(PROXYGEN_TIMESTAMP) || :
@@ -57,4 +57,6 @@ $(PROXYGEN_TIMESTAMP): aws--login $(SWAGGER_APIGEE) $(WORKSPACE_OUTPUT_JSON)
5757
AWS_ACCESS_KEY_ID=$(AWS_ACCESS_KEY_ID) \
5858
AWS_SECRET_ACCESS_KEY=$(AWS_SECRET_ACCESS_KEY) \
5959
AWS_SESSION_TOKEN=$(AWS_SESSION_TOKEN) \
60-
bash $(PATH_TO_INFRASTRUCTURE)/apigee/proxygen.sh generate_proxy
60+
bash $(PATH_TO_INFRASTRUCTURE)/apigee/proxygen.sh generate_proxy $(PERSISTENT_ENVIRONMENT_BUILD)
61+
62+
touch $(PROXYGEN_TIMESTAMP)

scripts/infrastructure/apigee/apigee.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ source ./scripts/infrastructure/terraform/terraform-constants.sh
55

66
PATH_TO_HERE="scripts/infrastructure/apigee"
77
APIGEE_DEPLOYMENT_ROLE="NHSDeploymentRole"
8+
PERSISTENT_ENVIRONMENT_BUILD="${2:-false}"
9+
API_NAME="connecting-party-manager"
10+
811

912

1013
if [[ -z ${WORKSPACE_OUTPUT_JSON} ]]; then
@@ -89,7 +92,12 @@ function attach_product(){
8992
_org_name="nhsd-nonprod"
9093
# Currently hardcoded to CPM PTL id for PR running purposes, could be passed in for adjusting other apps in the future
9194
_app_id="9d28b416-311b-4523-bda9-686baa2fc437"
92-
_product_name="connecting-party-manager--$_apigee_environment--cpm-$_workspace_name--app-level0"
95+
96+
if [ "$PERSISTENT_ENVIRONMENT_BUILD" = "false" ]; then
97+
API_NAME=$_workspace_name
98+
fi
99+
100+
_product_name="connecting-party-manager--$_apigee_environment--$API_NAME--app-level0"
93101
_secret_name="$_aws_environment--apigee-app-client-info"
94102
_apigee_stage=$(get_apigee_stage ${_workspace_name})
95103

@@ -146,7 +154,6 @@ function attach_product(){
146154
-H "Content-type:application/json" \
147155
-d "{\"apiProducts\": [\"$_product_name\"]}")
148156

149-
echo "$add_product_response"
150157
status=$(echo "$add_product_response" | jq -r '.status')
151158
echo "$status"
152159

@@ -171,7 +178,12 @@ function detach_product(){
171178
_org_name="nhsd-nonprod"
172179
# Currently hardcoded to CPM PTL id for PR running purposes, could be passed in for adjusting other apps in the future
173180
_app_id="9d28b416-311b-4523-bda9-686baa2fc437"
174-
_product_name="connecting-party-manager--$_apigee_environment--cpm-$_workspace_name--app-level0"
181+
182+
if [ "$PERSISTENT_ENVIRONMENT_BUILD" = "false" ]; then
183+
API_NAME=$_workspace_name
184+
fi
185+
186+
_product_name="connecting-party-manager--$_apigee_environment--$API_NAME--app-level0"
175187
_secret_name="$_aws_environment--apigee-app-client-info"
176188
_apigee_stage=$(get_apigee_stage ${_workspace_name})
177189

@@ -228,7 +240,6 @@ function detach_product(){
228240
-H "Content-type:application/json" \
229241
-d "{\"apiProducts\": [\"$_product_name\"]}")
230242

231-
echo "$detach_product_response"
232243
status=$(echo "$detach_product_response" | jq -r '.status')
233244
echo "$status"
234245

scripts/infrastructure/apigee/proxygen.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ set -e
22

33
PATH_TO_HERE="scripts/infrastructure/apigee"
44
APIGEE_DEPLOYMENT_ROLE="NHSDeploymentRole"
5+
API_NAME="connecting-party-manager"
6+
PERSISTENT_ENVIRONMENT_BUILD="${2:-false}"
7+
echo "PERSISTENT_ENVIRONMENT_BUILD is: $PERSISTENT_ENVIRONMENT_BUILD"
8+
59

610
if [[ -z ${WORKSPACE_OUTPUT_JSON} ]]; then
711
echo "WORKSPACE_OUTPUT_JSON not set"
@@ -107,11 +111,15 @@ function generate_proxy(){
107111
poetry run python ${PATH_TO_HERE}/download_pem.py ${_apigee_stage} ${APIGEE_DEPLOYMENT_ROLE}
108112
fi
109113

114+
if [ "$PERSISTENT_ENVIRONMENT_BUILD" = "false" ]; then
115+
API_NAME=$_workspace_name
116+
fi
117+
110118
DOT_PROXYGEN=${APIGEE_CONFIG_PATH}/${_apigee_stage} \
111119
poetry run \
112120
python ${PATH_TO_HERE}/proxygen.py instance deploy \
113121
${_apigee_environment} \
114-
cpm-${_workspace_name} \
122+
${API_NAME} \
115123
${SWAGGER_APIGEE} \
116124
--no-confirm
117125
}
@@ -153,6 +161,10 @@ function delete_proxy(){
153161
_workspace_name="sandbox"
154162
fi
155163

164+
if [ "$PERSISTENT_ENVIRONMENT_BUILD" = "false" ]; then
165+
API_NAME=$_workspace_name
166+
fi
167+
156168
# Download the pem file if it does not exist
157169
if [ ! -f "${APIGEE_CONFIG_PATH}/${_apigee_stage}/.proxygen/private_key.pem" ]; then
158170
poetry run python ${PATH_TO_HERE}/download_pem.py ${_apigee_stage} ${APIGEE_DEPLOYMENT_ROLE}
@@ -162,7 +174,7 @@ function delete_proxy(){
162174
poetry run \
163175
python ${PATH_TO_HERE}/proxygen.py instance delete \
164176
${_apigee_environment} \
165-
cpm-${_workspace_name} \
177+
${API_NAME} \
166178
--no-confirm
167179
}
168180

src/api/tests/smoke_tests/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,14 @@
1111
"int-sandbox": "sandbox",
1212
"prod": "",
1313
}
14+
15+
PERSISTENT_ENVIRONMENTS = [
16+
"dev",
17+
"dev-sandbox",
18+
"qa",
19+
"qa-sandbox",
20+
"ref",
21+
"int",
22+
"int-sandbox",
23+
"prod",
24+
]

src/api/tests/smoke_tests/tests/test_smoke_test_utils.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,42 @@
99
(
1010
"dev",
1111
"dev",
12-
"https://internal-dev.api.service.nhs.uk/cpm-dev",
12+
"https://internal-dev.api.service.nhs.uk/connecting-party-manager",
1313
),
1414
(
1515
"dev-sandbox",
1616
"dev",
17-
"https://internal-dev-sandbox.api.service.nhs.uk/cpm-dev-sandbox",
17+
"https://internal-dev-sandbox.api.service.nhs.uk/connecting-party-manager",
1818
),
1919
(
2020
"qa",
2121
"qa",
22-
"https://internal-qa.api.service.nhs.uk/cpm-qa",
22+
"https://internal-qa.api.service.nhs.uk/connecting-party-manager",
2323
),
2424
(
2525
"qa-sandbox",
2626
"qa",
27-
"https://internal-qa-sandbox.api.service.nhs.uk/cpm-qa-sandbox",
27+
"https://internal-qa-sandbox.api.service.nhs.uk/connecting-party-manager",
2828
),
2929
(
3030
"ref",
3131
"ref",
32-
"https://ref.api.service.nhs.uk/cpm-ref",
32+
"https://ref.api.service.nhs.uk/connecting-party-manager",
3333
),
3434
(
3535
"int",
3636
"int",
37-
"https://int.api.service.nhs.uk/cpm-int",
37+
"https://int.api.service.nhs.uk/connecting-party-manager",
3838
),
3939
(
4040
"int-sandbox",
4141
"int",
42-
"https://sandbox.api.service.nhs.uk/cpm-int-sandbox",
42+
"https://sandbox.api.service.nhs.uk/connecting-party-manager",
4343
),
4444
(
4545
"prod",
4646
"prod",
47-
"https://api.service.nhs.uk/cpm-prod",
47+
"https://api.service.nhs.uk/connecting-party-manager",
4848
),
4949
],
5050
)
@@ -60,22 +60,22 @@ def test_get_base_url_persistent_workspaces(
6060
(
6161
"foobar",
6262
"dev",
63-
"https://internal-dev.api.service.nhs.uk/cpm-foobar",
63+
"https://internal-dev.api.service.nhs.uk/foobar",
6464
),
6565
(
6666
"foobar-sandbox",
6767
"dev",
68-
"https://internal-dev.api.service.nhs.uk/cpm-foobar-sandbox",
68+
"https://internal-dev.api.service.nhs.uk/foobar-sandbox",
6969
),
7070
(
7171
"foobar",
7272
"qa",
73-
"https://internal-qa.api.service.nhs.uk/cpm-foobar",
73+
"https://internal-qa.api.service.nhs.uk/foobar",
7474
),
7575
(
7676
"foobar-sandbox",
7777
"qa",
78-
"https://internal-qa.api.service.nhs.uk/cpm-foobar-sandbox",
78+
"https://internal-qa.api.service.nhs.uk/foobar-sandbox",
7979
),
8080
],
8181
)

src/api/tests/smoke_tests/utils.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import boto3
55
import requests
66

7-
from .config import APIGEE_BASE_URL, APIGEE_URL_PREFIX_BY_ENVIRONMENT
7+
from .config import (
8+
APIGEE_BASE_URL,
9+
APIGEE_URL_PREFIX_BY_ENVIRONMENT,
10+
PERSISTENT_ENVIRONMENTS,
11+
)
812

913

1014
class SmokeTestError(Exception):
@@ -30,13 +34,18 @@ def get_headers(app_key: str) -> dict:
3034

3135

3236
def get_base_url(workspace: str, environment: str) -> str:
37+
api_name = "connecting-party-manager"
3338
apigee_url_prefix = (
3439
APIGEE_URL_PREFIX_BY_ENVIRONMENT[workspace]
3540
if workspace == f"{environment}-sandbox"
3641
else APIGEE_URL_PREFIX_BY_ENVIRONMENT[environment]
3742
)
3843
base_url = ".".join(filter(bool, (apigee_url_prefix, APIGEE_BASE_URL)))
39-
return f"https://{base_url}/cpm-{workspace}"
44+
45+
if workspace not in PERSISTENT_ENVIRONMENTS:
46+
api_name = workspace
47+
48+
return f"https://{base_url}/{api_name}"
4049

4150

4251
def is_2xx(status_code: int):

0 commit comments

Comments
 (0)