Skip to content

Commit a3ecaf5

Browse files
committed
wb | cardano-profile utils
1 parent c99980f commit a3ecaf5

File tree

4 files changed

+150
-2
lines changed

4 files changed

+150
-2
lines changed

nix/workbench/profile/pparams/api-pparams-to-genesis.jq renamed to bench/cardano-profile/utils/api-pparams-to-genesis.jq

File renamed without changes.

nix/workbench/profile/pparams/apiPparamsImport.sh renamed to bench/cardano-profile/utils/apiPparamsImport.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ jq --null-input '
44
include "api-pparams-to-genesis";
55
66
cardano_api_pparams_to_geneses($pparams[0]; $desc)
7-
' --slurpfile pparams ${1:?USAGE: $0 CARDANO-API-PPARAMS-JSON} \
8-
--arg desc "Imported from $(basename $1)" \
7+
' --slurpfile pparams "${1:?USAGE: $0 CARDANO-API-PPARAMS-JSON}" \
8+
--arg desc "Imported from $(basename "$1")" \
99
--sort-keys
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
#!/bin/bash
2+
3+
# Directories with all the profiles and its files to compare.
4+
echo "- Directory 1: $1"
5+
echo "- Directory 2: $2"
6+
7+
# TODO:
8+
# backend="supervisor"
9+
10+
for sup_file_name in "$1"/*
11+
do
12+
13+
profile_name="$(basename "${sup_file_name}")"
14+
echo -e "\n\n\n"
15+
echo "---------- ---------- ---------- ----------"
16+
echo "---------- ${profile_name}:"
17+
echo "---------- ---------- ---------- ----------"
18+
echo -e "\n\n\n"
19+
20+
# Profile files.
21+
echo "---------- ---------- profile:"
22+
for filepath in "$1"/"${profile_name}"/profile/*
23+
do
24+
filename="$(basename "${filepath}")"
25+
echo "---------- ---------- ---------- ${filename}:"
26+
if test "${filename}" = "profile.json"
27+
then
28+
dyff between \
29+
"$1/${profile_name}/profile/${filename}" \
30+
"$2/${profile_name}/profile/${filename}" \
31+
|| read -r
32+
elif test "${filename}" = "generator-service.json" \
33+
|| test "${filename}" = "healthcheck-service.json" \
34+
|| test "${filename}" = "tracer-service.json"
35+
then
36+
for key in $(jq -r 'keys | join (" ")' "$1/${profile_name}/profile/${filename}")
37+
do
38+
echo "---------- ---------- ---------- ---------- ${key}:"
39+
if test "${key}" = "name"
40+
then
41+
name1="$(jq -r ".name" "$1/${profile_name}/profile/${filename}")"
42+
name2="$(jq -r ".name" "$2/${profile_name}/profile/${filename}")"
43+
if ! test "$name1" = "$name2"
44+
then
45+
echo "${name1} /= ${name2}"
46+
exit 1
47+
fi
48+
else
49+
diff \
50+
"$(jq -r ".[\"${key}\"]" "$1/${profile_name}/profile/${filename}")" \
51+
"$(jq -r ".[\"${key}\"]" "$2/${profile_name}/profile/${filename}")" \
52+
|| read -r
53+
fi
54+
done
55+
elif test "${filename}" = "node-services.json"
56+
then
57+
for index in $(jq -r 'keys | join (" ")' "$1/${profile_name}/profile/${filename}")
58+
do
59+
for key in $(jq -r ".[\"${index}\"] | keys | join (\" \")" "$1/${profile_name}/profile/${filename}")
60+
do
61+
echo "---------- ---------- ---------- ---------- .[${index}].${key}:"
62+
if test "${key}" = "name"
63+
then
64+
name1="$(jq -r ".[\"${index}\"].name" "$1/${profile_name}/profile/${filename}")"
65+
name2="$(jq -r ".[\"${index}\"].name" "$2/${profile_name}/profile/${filename}")"
66+
if ! test "$name1" = "$name2"
67+
then
68+
echo "${name1} /= ${name2}"
69+
exit 1
70+
fi
71+
else
72+
diff \
73+
"$(jq -r ".[\"${index}\"].${key}" "$1/${profile_name}/profile/${filename}")" \
74+
"$(jq -r ".[\"${index}\"].${key}" "$2/${profile_name}/profile/${filename}")" \
75+
|| read -r
76+
fi
77+
done
78+
done
79+
elif test "${filename}" = "workloads-service.json"
80+
then
81+
for index in $(jq -r 'keys | join (" ")' "$1/${profile_name}/profile/${filename}")
82+
do
83+
for key in $(jq -r ".[${index}] | keys | join (\" \")" "$1/${profile_name}/profile/${filename}")
84+
do
85+
echo "---------- ---------- ---------- ---------- .[${index}].${key}:"
86+
if test "${key}" = "name"
87+
then
88+
name1="$(jq -r ".[${index}].name " "$1/${profile_name}/profile/${filename}")"
89+
name2="$(jq -r ".[${index}].name " "$2/${profile_name}/profile/${filename}")"
90+
if ! test "$name1" = "$name2"
91+
then
92+
echo "${name1} /= ${name2}"
93+
exit 1
94+
fi
95+
else
96+
diff \
97+
"$(jq -r ".[${index}].${key} " "$1/${profile_name}/profile/${filename}")" \
98+
"$(jq -r ".[${index}].${key} " "$2/${profile_name}/profile/${filename}")" \
99+
|| read -r
100+
fi
101+
done
102+
done
103+
else
104+
diff \
105+
"$1/${profile_name}/profile/${filename}" \
106+
"$2/${profile_name}/profile/${filename}" \
107+
|| read -r
108+
fi
109+
done
110+
111+
file1="$(mktemp)"
112+
file2="$(mktemp)"
113+
# Backend files.
114+
echo "---------- ---------- Backend files:"
115+
for filepath in "$1"/"$profile_name"/backend/*
116+
do
117+
filename="$(basename "${filepath}")"
118+
if test "${filename}" = "container-specs.json"
119+
then
120+
jq '.nomadJob.cloud.nomadExec |= null | .nomadJob.cloud.ssh |= null' "$1/${profile_name}/backend/${filename}" > "${file1}"
121+
jq '.nomadJob.cloud.nomadExec |= null | .nomadJob.cloud.ssh |= null' "$2/${profile_name}/backend/${filename}" > "${file2}"
122+
dyff between "${file1}" "${file2}"
123+
# jq -r '.nomadJob.cloud.nomadExec' "$1/${profile_name}/backend/${filename}" > "${file1}"
124+
# jq -r '.nomadJob.cloud.nomadExec' "$2/${profile_name}/backend/${filename}" > "${file2}"
125+
# dyff between "${file1}" "${file2}"
126+
# jq -r '.nomadJob.cloud.ssh' "$1/${profile_name}/backend/${filename}" > "${file1}"
127+
# jq -r '.nomadJob.cloud.ssh' "$2/${profile_name}/backend/${filename}" > "${file2}"
128+
# dyff between "${file1}" "${file2}"
129+
else
130+
echo "---------- ---------- ---------- ${filename}"
131+
diff \
132+
"$1/${profile_name}/backend/${filename}" \
133+
"$2/${profile_name}/backend/${filename}" \
134+
|| read -r
135+
fi
136+
done
137+
138+
done
139+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
cabal -v0 run cardano-profile names-noera | jq -r .[] | xargs -n 1 sh -c "nix-shell -A \"workbench-shell\" --max-jobs 8 --cores 0 --quiet --argstr profileName \"\$0-coay\" --argstr backendName supervisor --command \"mkdir -p /tmp/supervisor/\$0-coay/{profile,backend}; cp -r \$WB_SHELL_PROFILE_DATA/* /tmp/supervisor/\$0-coay/profile/; cp -r \$WB_BACKEND_DATA/* /tmp/supervisor/\$0-coay/backend/;\" || exit 255"
4+
5+
# Makefile
6+
# test-supervisor:
7+
# jq -r .[] all-profiles-names.noera.json | grep --invert-match "\-nomadperf" | xargs -n 1 sh -c 'nix-shell -A "workbench-shell" --max-jobs 8 --cores 0 --quiet --argstr profileName "$$0-coay" --argstr backendName supervisor --command "mkdir -p /tmp/supervisor/$$0-coay/{profile,backend}; cp -r \$$WB_SHELL_PROFILE_DATA/* /tmp/supervisor/$$0-coay/profile/; cp -r \$$WB_BACKEND_DATA/* /tmp/supervisor/$$0-coay/backend/;" || exit 255'
8+
# test-nomadcloud:
9+
# jq -r .[] all-profiles-names.noera.json | grep "\-nomadperf" | xargs -n 1 sh -c 'nix-shell -A "workbench-shell" --max-jobs 8 --cores 0 --quiet --argstr profileName "$$0-coay" --argstr backendName nomadcloud --command "mkdir -p /tmp/nomadcloud/$$0-coay/{profile,backend}; cp -r \$$WB_SHELL_PROFILE_DATA/* /tmp/nomadcloud/$$0-coay/profile/; cp -r \$$WB_BACKEND_DATA/* /tmp/nomadcloud/$$0-coay/backend/;" || exit 255'

0 commit comments

Comments
 (0)