Skip to content

Commit

Permalink
Fix message pull
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu committed Sep 20, 2024
1 parent cfa710e commit b9262a5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ jobs:
bin/setup_base
bin/clone_model
- name: local setup
run: bin/start_local sites/udmi_site_model $TARGET_PROJECT
- name: message capture
run: bin/pull_mqtt ZZ-TRI-FECTA > /tmp/message_capture.log &
run: |
bin/start_local sites/udmi_site_model $TARGET_PROJECT
bin/pull_messages $TARGET_PROJECT ZZ-TRI-FECTA > /tmp/message_capture.log &
- name: bin/test_automapper
run: bin/test_automapper $TARGET_PROJECT
- name: extra devices
Expand Down
20 changes: 20 additions & 0 deletions bin/pull_messages
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -e

UDMI_ROOT=$(dirname $0)/..
cd $UDMI_ROOT

source $UDMI_ROOT/etc/shell_common.sh

[[ $# == 2 ]] || usage project_spec suffix

project_spec=$1
suffix=$2
shift

if [[ $project_spec =~ //mqtt/ ]]; then
bin/pull_mqtt $project_spec $suffix
elif [[ $project_spec =~ //gbos/ ]]; then
bin/pull_pubsub $project_spec $suffix
else
fail unknown project spec type $project_spec
fi
7 changes: 4 additions & 3 deletions bin/pull_mqtt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ cd $UDMI_ROOT

source $UDMI_ROOT/etc/shell_common.sh

[[ $# == 1 ]] || usage registry_id
[[ $# == 2 ]] || usage project_spec registry_id

registry_id=$1
shift
project_spec=$1
registry_id=$2
shift 2

msg_file=/tmp/message_captured.json

Expand Down
15 changes: 11 additions & 4 deletions bin/pull_pubsub
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ kubectl config current-context | tr _ ' ' > /tmp/namespace_tmp
# Result is something like: gke bos-platform-dev us-central1 main grafnu
read < /tmp/namespace_tmp gcp project_id region cluster namespace

if [[ -n $1 ]]; then
subscription=$1
else
subscription=$namespace~debug
[[ $# -le 2 ]] || usage project_spec suffix
project_spec=$1
suffix=$2
shift 2 || true

if [[ -n $project_spec ]]; then
expected=//gbos/$project_id/$namespace
[[ $project_spec == $expected ]] || fail project spec $project_spec does not match expected $expected
fi

[[ -n $suffix ]] || suffix=debug
subscription=$namespace~${suffix}
echo Pulling from subscription $subscription

tmp_file=/tmp/message_captured.json
Expand Down

0 comments on commit b9262a5

Please sign in to comment.