Skip to content

Instantly share code, notes, and snippets.

@LalatenduMohanty
Created December 12, 2019 16:13
Show Gist options
  • Save LalatenduMohanty/5f78268e9477557f1cd873933e927c68 to your computer and use it in GitHub Desktop.
Save LalatenduMohanty/5f78268e9477557f1cd873933e927c68 to your computer and use it in GitHub Desktop.
cincinnati Justfile
TOPLEVEL_DIR=`git rev-parse --show-toplevel`
code:
code -n {{TOPLEVEL_DIR}}
format:
cargo fmt --all
commit +args="": format
git commit {{args}}
build:
cargo build
_coverage:
cargo kcov --verbose --all --no-clean-rebuild --open
coverage: test _coverage
test-pwd +args="":
#!/usr/bin/env bash
set -e
export RUST_BACKTRACE=0 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
just -v test-net-private
_test component features='test-net,test-net-private' rustcargs='--ignored':
#!/usr/bin/env bash
set -xe
(pushd {{component}} && cargo test --features {{features}} -- {{rustcargs}})
test-net-private:
#!/usr/bin/env bash
set -e
just _test quay "test-net,test-net-private" ""
just _test cincinnati "test-net,test-net-private" ""
just _test graph-builder "test-net,test-net-private" ""
path_prefix = "api/upgrades_info/"
get-and-display-graph:
just get-graph-gb | jq -cM | {{invocation_directory()}}/hack/graph.sh | dot -Tsvg > graph.svg; xdg-open graph.svg
run-graph-builder registry="https://quay.io" repository="openshift-release-dev/ocp-release" credentials_file="${HOME}/.docker/config.json":
#!/usr/bin/env bash
export RUST_BACKTRACE=1
export RUST_LOG="graph_builder=trace,graph-builder=trace,cincinnati=trace"
# export RUST_LOG="${RUST_LOG},dkregistry=trace"
# strace -f -D -o gb.strace.lol
cargo run --package graph-builder -- --upstream.registry.pause_secs 30 --address 0.0.0.0 --registry {{registry}} --repository {{repository}} -vvv --service.path_prefix {{path_prefix}} --credentials-file {{credentials_file}} # --disable-quay-api-metadata
run-graph-builder-satellite:
just run-graph-builder 'sat-r220-02.lab.eng.rdu2.redhat.com' 'default_organization-custom-ocp'
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://localhost:8080/{{path_prefix}}v1/graph' --service.mandatory_client_parameters='channel'
kill-daemons:
pkill graph-builder
pkill policy-engine
run-daemons:
#!/usr/bin/env bash
just run-graph-builder #"https://quay.io" "redhat/openshift-cincinnati-test-public-manual" ~/.docker/config.json 2>&1 &
PG_PID=$!
just run-policy-engine 2>&1 &
PE_PID=$!
trap "kill $PG_PID $PE_PID" EXIT
while true; do sleep 30; done
get-graph port channel arch host="http://localhost":
curl --header 'Accept:application/json' {{host}}:{{port}}/{{path_prefix}}v1/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}}v1/openapi | jq .
get-openapi-staging:
just get-openapi https://api.stage.openshift.com 443
j
get-openapi-production:
just get-openapi https://api.openshift.com 443
mem-debug-start:
echo > mem-debug.txt
while true; do ps --no-headers -C graph-builder -o rss -p $(pgrep -a graph-builder | awk '{ print $1 }') | tee -a mem-debug.txt; sleep 1; done
mem-debug-eval:
cat mem-debug.txt | uniq -c | grep -vE '^ +[1-3]' | awk '{ print $2 }' | tee mem-debug-filtered.txt
get-image-manifest tag repo='openshift-release-dev/ocp-release':
#!/usr/bin/env bash
set -xe
curl --get https://quay.io/v2/{{repo}}/manifests/{{tag}} | jq .
get-quay-labels tag repo='openshift-release-dev/ocp-release':
#!/usr/bin/env bash
set -xe
manifestref=`curl --head https://quay.io/v2/{{repo}}/manifests/{{tag}} | rg 'docker-content-digest: (sha256:[a-z0-9]{64}).*$' -r '$1'`
curl --get https://quay.io/api/v1/repository/{{repo}}/manifest/${manifestref}/labels | jq .
testrg:
#!/usr/bin/env bash
set -xe
var=`echo 'hello\nrg\n' | rg '^(hello).*$' -r '$1'`
_promquery query:
curl --get -g --header "Authorization: Bearer $(pass show Webservices/console.app-sre.openshift.com | jq -r '.token')" 'https://infogw-data.api.openshift.com/api/v1/query' --data-urlencode 'query={{query}}' --data-urlencode 'time=2019-03-08T14:45:34.000067500+00:00'
promquery:
just _promquery '\
avg by (version) (count by (version) (cluster_version{type="failure"}) / on (version) count by (version) (cluster_version)) \
'
# count by (version) (cluster_version{type="failure"}) / on (version) count by (version) (cluster_version) \
test-prometheus:
#!/usr/bin/env bash
set -e
export PROMETHEUS_API_TOKEN=`pass show Webservices/console.app-sre.openshift.com | jq -r '.token'`
set -x
export RUST_LOG="prometheus_query=trace"
cd {{TOPLEVEL_DIR}}/prometheus-query
# cargo test v1::queries::instant::tests::query --features test-net-private -- --color=always --ignored
cd {{TOPLEVEL_DIR}}/cincinnati
cargo test plugins::internal::phased_rollouts::tests::test_plugin --features test-net-private -- --color=always # --nocapture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment