Skip to content

Commit 5a9d396

Browse files
committed
Incremental/bug fixes.
1 parent ae07042 commit 5a9d396

File tree

6 files changed

+60
-56
lines changed

6 files changed

+60
-56
lines changed

dev-local/.env.container

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ RUNNING_IN_LOCAL_STACK="${RUNNING_IN_LOCAL_STACK}"
5151
SUPER_USER_EMAIL="${SUPER_USER_EMAIL}"
5252
SUPER_USER_NAME="${SUPER_USER_NAME}"
5353
SUPER_USER_PASSWORD="${SUPER_USER_PASSWORD}"
54+
LOCAL_TESTING_TARGET="${LOCAL_TESTING_TARGET}"

dev-local/Dockerfile.local

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# FIXME: Update to most recent python.
21
FROM python:3.11-trixie
32

4-
# FIXME: Uncertain implications
53
ENV PYTHONUNBUFFERED=1
64
ENV PYDEVD_DISABLE_FILE_VALIDATION=1
75

@@ -24,8 +22,6 @@ USER DEV
2422
ADD .. /code
2523
WORKDIR /code
2624

27-
# FIXME: Is this how to use venvs
28-
# reliably in a Dockerfile?
2925
RUN python -m venv /tmp/venv
3026
RUN . /tmp/venv/bin/activate
3127
ENV PATH="/tmp/venv/bin:${PATH}"

dev-local/README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The containerized local build should provide a local development experience that
88

99
These tools assume you are a developer working on the project, and have access to the VPN and other systems.
1010

11+
## TL;DR
12+
13+
14+
1115
## pre-requisites
1216

1317
It is assumed you have a *NIX-like shell, and have the ability to run GNU Make or a reasonable fascimilie thereof.
@@ -16,7 +20,7 @@ A Mac, out-of-the-box, should "just work," as well as an Intel-based Linux host.
1620

1721
### configuring `kion`
1822

19-
*To run the tools, you must be in a `kion` shell. What follows is a way to set up an alias that makes running the correct configuration easier.*
23+
*To run the tools, you must be in a `kion` shell. What follows is a way to set up an alias that makes running the correct configuration easier. You can also run `kion stak` or `kion s` and navigate the menus to achieve a similar result.*
2024

2125
You should already have a `.kion.yaml` in your home directory. If not, follow the [local desktop development](https://confluence.cms.gov/spaces/BB2/pages/484224999/Local+Desktop+Development) onboarding docs to set up Cloudtamer/`kion`.
2226

@@ -31,7 +35,7 @@ Then add the alias as:
3135

3236
```
3337
favorites:
34-
- name: BB2-NON-PROD
38+
- name: bbnp
3539
account: <account-number>
3640
cloud_access_role: <cloud-access-role>
3741
access_type: cli
@@ -40,10 +44,10 @@ favorites:
4044
If you already have some aliases, you can just add this one to the list. The account number and cloud access role can be obtained from the Cloudtamer dashboard. This is not strictly necessary, as the tooling cannot automate a `kion` call *and* then continue, as `kion` opens a new shell. However, it is much easier (and, for this documentation, the preferred method) to invoke
4145

4246
```
43-
kion f BB2-NON-PROD
47+
kion f bbnp
4448
```
4549

46-
than to navigate a menu structure. You may ultimately choose a shorter alias, e.g. `kion f bnp`.
50+
than to navigate a menu structure. You may ultimately choose a shorter alias, e.g. `kion f bbnp`.
4751

4852
## to start
4953

@@ -93,26 +97,36 @@ make run-local bfd=test auth=live
9397

9498
Each combination has different implications. Only some make sense at this time (Nov '25):
9599

96-
| bfd / auth | mock | live |
100+
| | auth=mock | auth=live |
97101
| --- | --- | --- |
98-
| local | local unit tests | testing SLSX sequences |
99-
| test || Full-up against `test` |
100-
| sbx || Full-up against `sbx` |
102+
| **bfd=local** | local unit tests | testing SLSX sequences |
103+
| **bfd=test** || Full-up against `test` |
104+
| **bfd=sbx** || Full-up against `sbx` |
101105

102106
* `local/mock`: This makes sense for running unit tests; only local tests will run in this configuration.
103-
* `local/live`: Manual testing of SLSX sequences should be able to be performed with this combination (TBD)
104-
* `test/mock`: Not a valid condition; a mock authentication will not work with a live server.
107+
* `local/live`: Manual testing of SLSX sequences should be able to be performed with this combination. No BFD/FHIR URLs are set, though, which may break things.
108+
* `test/mock`: *Not a valid condition*; a mock authentication will not work with a live server.
105109
* `test/live`: Live SLSX exchanges with medicare.gov and calls against the `test` BFD environment.
106-
* `sbx/mock`: Not a valid condition.
110+
* `sbx/mock`: *Not a valid condition*.
107111
* `sbx/live`: Live SLSX exchanges and calls against the `sbx` BFD environment.
108112

109113

114+
### running daemonized
115+
116+
You cann add `daemon=1` to any of the above commands, and the stack will run in the background.
117+
118+
For example:
119+
120+
```
121+
make run-local bfd=test auth=live daemon=1
122+
```
123+
110124
### running against `test`
111125

112126
When launched with
113127

114128
```
115-
make run-local TARGET=test
129+
make run-local bfd=test auth=live
116130
```
117131

118132
the tooling obtains and sources credentials for running against our `test` environment.
@@ -122,7 +136,7 @@ the tooling obtains and sources credentials for running against our `test` envir
122136
Similarly,
123137

124138
```
125-
make run-local TARGET=sbx
139+
make run-local bfd=sbx auth=live
126140
```
127141

128142
runs against SBX.
@@ -135,9 +149,9 @@ runs against SBX.
135149

136150
In a nutshell:
137151

138-
1. Run `kion f BB2-NON-PROD` to authenticate/obtain AWS credentials.
152+
1. Run `kion f bbnp` to authenticate/obtain AWS credentials.
139153
1. Obtain certificates for the remote environment (if you selected `test` or `sbx`)
140-
1. `docker compose --profile mock-sls up` for `local`, `docker compose --profile slsx up` for live envs.
154+
1. Pass appropriate env vars through to the app, based on choices.
141155

142156
## future work
143157

dev-local/docker-compose-local.yaml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,4 @@ services:
3636
- "5678:5678"
3737
depends_on:
3838
- db
39-
- msls
40-
41-
# web_msls:
42-
# build: .
43-
# command: ./start-local.sh
44-
# env_file:
45-
# - .env.local
46-
# volumes:
47-
# - ..:/code
48-
# - ~/.bb2/certstore:/certstore
49-
# ports:
50-
# - "8000:8000"
51-
# - "5678:5678"
52-
# depends_on:
53-
# - db
54-
# - msls
55-
# profiles:
56-
# - mocksls
57-
# platform: linux/amd64
58-
# unittests:
59-
# build: .
60-
# command: python3 -m debugpy --listen 0.0.0.0:6789 --wait-for-client runtests.py
61-
# env_file:
62-
# - docker-compose/unittests-env-vars.env
63-
# ports:
64-
# - "6789:6789"
65-
# volumes:
66-
# - .:/code
67-
# profiles:
68-
# - tests
39+
- msls

dev-local/run-tests-in-both-environments.bash

Lines changed: 0 additions & 4 deletions
This file was deleted.

dev-local/utility-functions.bash

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,27 @@ check_valid_env () {
1919
#####
2020
# ERR
2121
else
22-
echo "'bfd' must be set to 'local', 'test', or 'sbx'."
23-
echo "'bfd' is currently set to '${bfd}'."
22+
echo "'bfd' must be set to 'local', 'test', or 'sbx'."
23+
echo "'bfd' is currently set to '${bfd}'."
2424
echo "Exiting."
2525
return -2
2626
fi
2727

28+
29+
if [[ "${bfd}" == "local" && "${auth}" == "live" ]]; then
30+
echo "⚠️ ${bfd}/${auth} may work for SLSX testing, but not for BFD calls."
31+
fi
32+
33+
if [[ "${bfd}" == "test" && "${auth}" == "mock" ]]; then
34+
echo "${bfd}/${auth} is not a valid combination. Exiting."
35+
return -3
36+
fi
37+
38+
if [[ "${bfd}" == "sbx" && "${auth}" == "mock" ]]; then
39+
echo "${bfd}/${auth} is not a valid combination. Exiting."
40+
return -4
41+
fi
42+
2843
echo "✅ check_valid_env"
2944
}
3045

@@ -96,16 +111,20 @@ set_bfd_urls () {
96111
if [[ "${bfd}" == "local" ]]; then
97112
echo "⚠️ No FHIR URLs set for local testing."
98113
echo " There are no mock BFD endpoints for local testing at this time."
114+
export LOCAL_TESTING_TARGET="local"
99115
#####
100116
# TEST
101117
elif [[ "${bfd}" == "test" ]]; then
102118
export FHIR_URL="${FHIR_URL_TEST}"
103119
export FHIR_URL_V3="${FHIR_URL_V3_TEST}"
120+
export LOCAL_TESTING_TARGET="test"
104121
#####
105122
# SBX
106123
elif [[ "${bfd}" == "sbx" ]]; then
107124
export FHIR_URL="${FHIR_URL_SBX}"
108125
export FHIR_URL_V3="${FHIR_URL_V3_SBX}"
126+
# FIXME: Do we use "impl" or "sbx"? ...
127+
export LOCAL_TESTING_TARGET="impl"
109128
fi
110129

111130
echo "✅ set_bfd_urls"
@@ -143,6 +162,10 @@ set_auth_profile () {
143162
export CERT_AND_SALT="YES"
144163

145164
retrieve_certs () {
165+
echo "🎁 Retrieving certs for the '${bfd}' environment with suffix '${CERT_SUFFIX}'."
166+
167+
unset CERT_SUFFIX
168+
146169
if [[ "${bfd}" == "local" ]]; then
147170
echo "🆗 Running locally. Not retrieving certs."
148171
echo "🆗 Running locally. Not retrieving salt."
@@ -173,10 +196,12 @@ retrieve_certs () {
173196
KEY="ca.key.nocrypt.pem"
174197

175198
# Remove them first
199+
echo " Removing ${BB2_CERTSTORE}/$CERT"
176200
rm -f "${BB2_CERTSTORE}/$CERT"
201+
echo " Removing ${BB2_CERTSTORE}/$KEY"
177202
rm -f "${BB2_CERTSTORE}/$KEY"
178203

179-
echo "🎁 Retrieving certs for the '${bfd}' environment with suffix '${CERT_SUFFIX}'."
204+
echo " Fetching ${BB2_CERTSTORE}/$CERT"
180205
aws secretsmanager get-secret-value \
181206
--secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_certificate${CERT_SUFFIX} \
182207
--query 'SecretString' \
@@ -187,6 +212,7 @@ retrieve_certs () {
187212
return -3
188213
fi
189214

215+
echo " Fetching ${BB2_CERTSTORE}/$KEY"
190216
aws secretsmanager get-secret-value \
191217
--secret-id /bb2/local_integration_tests/fhir_client/certstore/local_integration_tests_private_key${CERT_SUFFIX} \
192218
--query 'SecretString' \

0 commit comments

Comments
 (0)