Skip to content

Commit fd44b4c

Browse files
committed
Improve dev environment setup and add utility to run backplane locally
1 parent ffbd06b commit fd44b4c

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ dist
55
.envrc
66
.idea
77
.vscode
8-
cad_testing
8+
cad_testing
9+
backplane-api

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,39 @@ They are initialized for you and passed to the investigation via investigation.R
9090
## Testing locally
9191

9292
### Pre-requirements
93-
- an existing cluster
94-
- an existing PagerDuty incident for the cluster and alert type that is being tested
93+
- An existing stage cluster
94+
- A Pagerduty incident
9595

96-
To quickly create an incident for a cluster_id, you can run `./test/generate_incident.sh <alertname> <clusterid>`.
97-
Example usage:`./test/generate_incident.sh ClusterHasGoneMissing 2b94brrrrrrrrrrrrrrrrrrhkaj`.
96+
```bash
97+
# (Optional) Export you pagerduty token to automatically retireve the incident id
98+
export pd_token=<your_pd_token>
99+
# Generates incident and creates payload file with incident ID
100+
./test/generate_incident.sh <alertname> <clusterid>
101+
```
98102

99-
### Running cadctl for an incident ID
100-
1) Export the required ENV variables, see [required ENV variables](#required-env-variables).
101-
2) Create a payload file containing the incident ID
103+
If you are not using pd_token, create the payload file with the incidentID manually
102104
```bash
103105
export INCIDENT_ID=
104106
echo '{"__pd_metadata":{"incident":{"id":"'${INCIDENT_ID}'"}}}' > ./payload
105107
```
108+
109+
### Running cadctl
110+
111+
1) Run backplane-api locally in a second terminal ( requires being logged into ocm )
112+
113+
```
114+
./test/backplane.sh
115+
```
116+
117+
> If there is an issue with this step, comment out the `BACKPLANE_URL` env in `set_stage_env.sh`. You will then run against stage backplane, meaning backplane wont be able to see any local changes to metadata files, expect errors like `file not found`
118+
2) Export the required ENV variables, see [required ENV variables](#required-env-variables).
119+
```
120+
source test/set_stage_env.sh
121+
```
106122
3) Run `cadctl` using the payload file
107-
```bash
108-
./bin/cadctl investigate --payload-path payload
109-
```
123+
```bash
124+
./bin/cadctl investigate --payload-path payload
125+
```
110126
111127
## Documentation
112128

test/backplane.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# clone
5+
git -C backplane-api pull || git clone --depth 1 --branch master [email protected]:service/backplane-api.git
6+
# build
7+
cd backplane-api
8+
make build
9+
# setup, this does not look to good :D
10+
sudo make dev-certs
11+
sudo chmod 644 localhost.key
12+
# setup ocm config
13+
cp $HOME/.config/ocm/ocm.json configs/ocm.json
14+
# run, in background? second terminal ?
15+
RUN_ARGS=--cloud-config=./configs/cloud-config.yml make run-local-with-testremediation GIT_REPO="../"
16+
17+

test/set_stage_env.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ for v in $(vault kv get -format=json osd-sre/configuration-anomaly-detection/pd
1010
unset VAULT_ADDR VAULT_TOKEN
1111

1212
export CAD_EXPERIMENTAL_ENABLED=true
13-
export BACKPLANE_PROXY=http://squid.corp.redhat.com:3128
13+
# export BACKPLANE_PROXY=http://squid.corp.redhat.com:3128
14+
export BACKPLANE_URL=https://localhost:8001
1415

1516
set +euo pipefail

0 commit comments

Comments
 (0)