forked from openshift/cincinnati
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
286 lines (223 loc) · 7.68 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
path_prefix := "api/upgrades_info/"
testdata_dir := "e2e/tests/testdata/"
metadata_revision_file := "metadata_revision"
metadata_reference :='reference_branch = "master"'
pause_secs := "9999999"
registry := "https://quay.io"
repository := "openshift-release-dev/ocp-release"
credentials_file := "${HOME}/.docker/config.json"
default_tracing_endpoint := "localhost:6831"
metadata_reference_e2e:
printf 'reference_revision = "%s"' "$(cat {{testdata_dir}}/{{metadata_revision_file}})"
metadata_reference_revision:
#!/usr/bin/env bash
read -r var <"{{testdata_dir}}"/metadata_revision; printf $var
format:
cargo fmt --all
clippy:
cargo clippy --all-targets --all-features
commit +args="": format
git commit {{args}}
build:
cargo build
_coverage:
cargo kcov --verbose --all --no-clean-rebuild --open
coverage: test _coverage
dashboards:
#!/usr/bin/env bash
for file in dist/grafana/*.json; do
cat <<EOF > dist/grafana/dashboards/$(basename $file .json).configmap.yaml
#This file is auto-generated from dist/grafana. Make changes there and run "just dashboards" to generate the file
apiVersion: v1
kind: ConfigMap
metadata:
name: $(basename $file .json)
labels:
grafana_dashboard: "true"
annotations:
grafana-folder: /grafana-dashboard-definitions/Cincinnati
data:
cincinnati.json: |-
$(sed 's/^/ /' $file)
EOF
done
test-pwd +args="":
#!/usr/bin/env bash
set -e
export RUST_BACKTRACE=1 RUST_LOG="graph-builder=trace,cincinnati=trace,dkregistry=trace"
pushd {{invocation_directory()}}
cargo test {{args}}
test: format
#!/usr/bin/env bash
set -e
export RUST_BACKTRACE=1 RUST_LOG="graph-builder=trace,cincinnati=trace,dkregistry=trace"
cargo test --all
_test component cargoargs='--features test-net,test-net-private' rustcargs='--ignored':
#!/usr/bin/env bash
set -xe
export RUST_BACKTRACE=1 RUST_LOG="graph-builder=trace,cincinnati=trace,dkregistry=trace"
(pushd {{component}} && cargo test -- --nocapture {{cargoargs}} -- {{rustcargs}})
test-net-private:
#!/usr/bin/env bash
set -e
just _test quay "--features test-net,test-net-private" ""
just _test cincinnati "--features test-net,test-net-private" ""
just _test graph-builder "--features test-net,test-net-private" ""
run-ci-tests:
#!/usr/bin/env bash
set -e
hack/run-all-tests.sh
# Runs the client part of the e2e test suite.
run-e2e-test-only filter="e2e":
#!/usr/bin/env bash
set -e
export GRAPH_URL='http://127.0.0.1:8081/{{path_prefix}}graph'
export E2E_METADATA_REVISION="$(just metadata_reference_revision)"
# we need to use the parent-directory here because the test runs in the graph-builder directory
export E2E_TESTDATA_DIR="../{{ testdata_dir }}"
just _test e2e "" "{{ filter }}"
# Spawns a Cincinnati stack on localhost and runs the e2e test suite.
run-e2e:
#!/usr/bin/env bash
set -e
just \
registry="{{registry}}" repository="{{repository}}" \
run-daemons-e2e > /dev/null 2>&1 &
trap "just kill-daemons" EXIT
# give the graph-builder time to scrape
sleep 180
for i in `seq 1 100`; do
just run-e2e-test-only && {
echo Test successful.
exit 0
} || {
echo Attempt failed. Trying again in 10 seconds.
sleep 10
}
done
echo Test failed.
exit 1
# Capture new e2e fixtures and refresh the metadata revision file.
e2e-fixtures-capture-only:
#!/usr/bin/env bash
set -e
for base in "stable"; do
for version in "4.2" "4.3"; do
for arch in "amd64" "s390x"; do
just get-graph-pe "${base}-${version}" "${arch}" | hack/graph-normalize.sh > {{testdata_dir}}/"$(just metadata_reference_revision)_${base}-${version}_${arch}".json
done
done
done
# Reads a graph on stdin, creates an SVG out of it and opens it with SVG-associated default viewer. Meant to be combined with one of the `get-graph-*` recipes.
display-graph:
#!/usr/bin/env bash
required_tools=("xdg-open" "dot" "jq")
for tool in "${required_tools[@]}"; do
type ${tool} >/dev/null 2>&1 || {
printf "ERROR: program '%s' not found, please install it.\n" "${tool}"
exit 1
}
done
jq -cM . | {{invocation_directory()}}/hack/graph.sh | dot -Tsvg > graph.svg; xdg-open graph.svg
run-metadata-helper:
#!/usr/bin/env bash
export RUST_BACKTRACE=1
cargo run --package metadata-helper -- -c <(cat <<-EOF
verbosity = "vvv"
[service]
address = "127.0.0.1"
port = 8082
path_prefix = "{{path_prefix}}"
tracing_endpoint = "{{default_tracing_endpoint}}"
[status]
address = "127.0.0.1"
port = 9082
## uncomment [signatures] block to add a custom graph-data directory. Without this config,
## metadata-helper will create temp dir to source signatures. MH does not have capability to fetch
## signatures from upstream. If directory is not provided, MH wont be able to serve signatures.
# [signatures]
# dir = "/tmp/graph-data/signatures"
EOF
)
run-graph-builder:
#!/usr/bin/env bash
export RUST_BACKTRACE=1
trap 'rm -rf "$TMPDIR"' EXIT
export TMPDIR=$(mktemp -d)
cargo run --package graph-builder -- -c <(cat <<-EOF
verbosity = "vvv"
[service]
scrape_timeout_secs = 300
pause_secs = {{pause_secs}}
address = "127.0.0.1"
port = 8080
path_prefix = "{{path_prefix}}"
tracing_endpoint = "{{default_tracing_endpoint}}"
[status]
address = "127.0.0.1"
port = 9080
[[plugin_settings]]
name="release-scrape-dockerv2"
registry = "{{registry}}"
repository = "{{repository}}"
fetch_concurrency=128
credentials_path = "{{credentials_file}}"
[[plugin_settings]]
name = "github-secondary-metadata-scrape"
github_org = "openshift"
github_repo = "cincinnati-graph-data"
branch = "master"
output_directory = "${TMPDIR}"
{{metadata_reference}}
[[plugin_settings]]
name = "openshift-secondary-metadata-parse"
[[plugin_settings]]
name = "edge-add-remove"
EOF
)
run-graph-builder-satellite:
just registry='sat-r220-02.lab.eng.rdu2.redhat.com' repository='default_organization-custom-ocp' run-graph-builder
run-graph-builder-e2e:
just \
registry="{{registry}}" repository="{{repository}}" \
metadata_reference="$(just metadata_reference_e2e)" \
run-graph-builder
run-policy-engine:
#!/usr/bin/env bash
export RUST_BACKTRACE=1 RUST_LOG="policy_engine=trace,cincinnati=trace,actix=trace,actix_web=trace"
cargo run --package policy-engine -- -vvvv --service.address 0.0.0.0 --service.path_prefix {{path_prefix}} --upstream.cincinnati.url 'http://127.0.0.1:8080/{{path_prefix}}graph' --service.mandatory_client_parameters='channel' --service.tracing_endpoint "{{default_tracing_endpoint}}"
kill-daemons:
pkill graph-builder
pkill policy-engine
run-daemons:
#!/usr/bin/env bash
just run-graph-builder 2>&1 &
PG_PID=$!
just run-policy-engine 2>&1 &
PE_PID=$!
trap "kill $PG_PID $PE_PID" EXIT
sleep infinity
run-daemons-e2e:
#!/usr/bin/env bash
just \
registry="{{registry}}" repository="{{repository}}" \
run-graph-builder-e2e 2>&1 &
just run-policy-engine 2>&1 &
trap "just kill-daemons" EXIT
sleep infinity
get-graph port channel arch host="http://127.0.0.1":
curl --header 'Accept:application/json' {{host}}:{{port}}/{{path_prefix}}graph?channel='{{channel}}'\&arch='{{arch}}' | jq .
get-graph-gb:
just get-graph 8080 "" ""
get-graph-pe channel='' arch='':
just get-graph 8081 "{{channel}}" "{{arch}}"
get-graph-pe-staging channel='stable-4.1' arch='amd64':
just get-graph 443 "{{channel}}" "{{arch}}" https://api.stage.openshift.com
get-graph-pe-production channel='stable-4.0' arch='amd64':
just get-graph 443 "{{channel}}" "{{arch}}" https://api.openshift.com
get-openapi host port:
curl --header 'Accept:application/json' {{host}}:{{port}}/{{path_prefix}}openapi | jq .
get-openapi-staging:
just get-openapi https://api.stage.openshift.com 443
get-openapi-production:
just get-openapi https://api.openshift.com 443