Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
5b9bff7b
Unverified
Commit
5b9bff7b
authored
Dec 13, 2023
by
Joshua Gutow
Committed by
GitHub
Dec 13, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8417 from testinprod-io/tip/delta-checker
op-chain-ops: Delta checker script
parents
2a68955e
a935f3b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
0 deletions
+101
-0
aggregate-channels.sh
op-chain-ops/cmd/check-delta/aggregate-channels.sh
+101
-0
No files found.
op-chain-ops/cmd/check-delta/aggregate-channels.sh
0 → 100755
View file @
5b9bff7b
#!/bin/bash
set
-uo
pipefail
# Check if a directory path is provided
# Directory must contain the output of batch_decoder's reassemble command, which are channels in json form
if
[
-z
"
${
1
:-}
"
]
;
then
echo
"Usage:
$0
/path/to/directory"
exit
1
fi
# Check if jq is installed
if
!
command
-v
jq &> /dev/null
;
then
echo
"Error: jq is not installed"
exit
1
fi
directory_path
=
$1
# Check if directory exists and is not empty
if
[
!
-d
"
$directory_path
"
]
||
[
-z
"
$(
ls
-A
"
$directory_path
"
)
"
]
;
then
echo
"Error: Directory does not exist or is empty"
exit
1
fi
invalid_json_count
=
0
invalid_jsons
=()
not_ready_channel_count
=
0
not_ready_channels
=()
ready_channel_count
=
0
span_batch_count
=
0
singular_batch_count
=
0
channels_with_invalid_batches
=()
batch_type_counter_jq_script
=
'reduce .batch_types[] as $batch_type (
{"span_batch_count": 0, "singular_batch_count": 0};
if $batch_type == 1 then
.span_batch_count += 1
else
.singular_batch_count += 1
end) | .span_batch_count, .singular_batch_count'
# Loop over every .json file in the specified directory
for
file
in
"
$directory_path
"
/
*
.json
;
do
# check file is valid json
if
!
jq empty
"
$file
"
2>/dev/null
;
then
((
invalid_json_count++
))
invalid_jsons+
=(
"
$file
"
)
continue
fi
# check channels are ready
if
[
$(
jq
-r
".is_ready"
"
$file
"
)
==
"false"
]
;
then
# not ready channel have no batches so invalid_batches field is always false
((
not_ready_channel_count++
))
not_ready_channels+
=(
"
$file
"
)
continue
else
((
ready_channel_count++
))
fi
# check channels contain invalid batches
if
[
$(
jq
-r
".invalid_batches"
"
$file
"
)
==
"true"
]
;
then
channels_with_invalid_batches+
=(
"
$file
"
)
fi
# count singular batch count and span batch count
jq_result
=
$(
jq
"
$batch_type_counter_jq_script
"
"
$file
"
)
read
span_batch_count_per_channel singular_batch_count_per_channel
<<<
$jq_result
span_batch_count
=
$((
span_batch_count+span_batch_count_per_channel
))
singular_batch_count
=
$((
singular_batch_count+singular_batch_count_per_channel
))
done
# Display the counts
echo
"Singular batch count:
$singular_batch_count
"
echo
"Span batch count:
$span_batch_count
"
echo
"Ready channel count:
$ready_channel_count
"
echo
"Not ready channel count:
$not_ready_channel_count
"
echo
"Invalid json count:
$invalid_json_count
"
# Display the files which are invalid jsons
if
[
${#
invalid_jsons
[@]
}
-gt
0
]
;
then
echo
"Invalid jsons"
printf
'[*] %s\n'
"
${
invalid_jsons
[@]
}
"
else
echo
"All processed channels are valid jsons."
fi
# Display the files which are channels not ready
if
[
${#
not_ready_channels
[@]
}
-gt
0
]
;
then
echo
"Not ready channels"
printf
'[*] %s\n'
"
${
not_ready_channels
[@]
}
"
else
echo
"All processed channels are ready."
fi
# Display the files including invalid batches
if
[
${#
channels_with_invalid_batches
[@]
}
-gt
0
]
;
then
echo
"Channels with invalid batches"
printf
'[*] %s\n'
"
${
channels_with_invalid_batches
[@]
}
"
else
echo
"All processed ready channels contain valid batches."
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment