-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pubber endpoint configuration working with mosquitto broker #497
Merged
Merged
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
20eb23d
Adding auth examples
grafnu 1d0cf89
Basic audience parsing
grafnu e2e7216
Cleanup
grafnu b3f7e1c
Basic jwt options
grafnu bfd4bdc
Add audience provider test
grafnu e331a84
Mosquitto basics
grafnu 53b9986
Change test order
grafnu 5de62d9
Updating test_mosquitto with password
grafnu dc95587
Script diagnostics
grafnu f6b406b
Adding help
grafnu 31c6ef0
Try different arguments
grafnu 2071344
Add mosquitto-clients
grafnu b03d795
Remove debug
grafnu fceb3eb
cleanup
grafnu e9164d0
Adding some options
grafnu 0bda1bf
Complete pubber check
grafnu d032589
Enable script debugging
grafnu df3ef13
Remove project_id dependency
grafnu 849d655
Adding option to configure/remove config startup wait time
grafnu 29ae18b
Update gencode hash
grafnu 702e607
Adding some test examples
grafnu c8e75bc
Fix pubber kill
grafnu e47c87c
Merge branch 'master' into endpoint
grafnu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash -e | ||
|
||
ROOT_DIR=$(dirname $0)/.. | ||
cd $ROOT_DIR | ||
|
||
if [[ $# != 0 ]]; then | ||
echo Usage: $0 | ||
false | ||
fi | ||
|
||
site_path=sites/udmi_site_model | ||
device_id=AHU-1 # Static device for testing. Needs to be different than other tests scripts so as not to conflict during CI. | ||
serial_no=$RANDOM | ||
|
||
site_config=$site_path/cloud_iot_config.json | ||
cloud_region=$(jq -r .cloud_region $site_config) | ||
registry_id=$(jq -r .registry_id $site_config) | ||
|
||
mkdir -p out | ||
PASSWORD_FILE=/etc/mosquitto/test_mosquitto.passwd | ||
USERNAME=scrumptus | ||
PASSWORD=aardvark | ||
|
||
echo password_file ${PASSWORD_FILE} | sudo tee /etc/mosquitto/conf.d/udmi_test.conf | ||
sudo sed -i 's/allow_anonymous true/allow_anonymous false/' /etc/mosquitto/mosquitto.conf | ||
sudo sed -i 's/#listener/listener/' /etc/mosquitto/mosquitto.conf | ||
|
||
sudo touch ${PASSWORD_FILE} | ||
sudo mosquitto_passwd -b ${PASSWORD_FILE} ${USERNAME} ${PASSWORD} | ||
sudo chmod 666 ${PASSWORD_FILE} | ||
|
||
sudo systemctl restart mosquitto | ||
systemctl status mosquitto | ||
killall mosquitto_sub || true | ||
|
||
echo Subscribing to mqtt/test in the background... | ||
mosquitto_sub -t \# -u ${USERNAME} -P ${PASSWORD} | tee out/mosquitto.sub & | ||
|
||
sleep 1 | ||
|
||
echo Publishing test message | ||
mosquitto_pub -t mqtt/test -u ${USERNAME} -P ${PASSWORD} -m "Hello MQTT" | ||
|
||
sleep 1 | ||
|
||
cat <<EOF > /tmp/pubber_config.json | ||
{ | ||
"endpoint": { | ||
"protocol": "mqtt", | ||
"transport": "tcp", | ||
"client_id": "$registry_id/$device_id", | ||
"hostname": "127.0.0.1", | ||
"port": 1883, | ||
"auth_provider": { | ||
"basic": { | ||
"username": "$USERNAME", | ||
"password": "$PASSWORD" | ||
} | ||
} | ||
}, | ||
"sitePath": "$site_path", | ||
"deviceId": "$device_id", | ||
"serialNo": "$serial_no" | ||
} | ||
EOF | ||
|
||
ps ax | fgrep java | fgrep /tmp/pubber_config.json | fgrep -v grep | awk '{print $1}' | xargs -r kill | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something like I'm doing eleswhere? function kill_existing() { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
|
||
$ROOT_DIR/pubber/bin/build | ||
|
||
timeout 10s $ROOT_DIR/pubber/bin/run /tmp/pubber_config.json || true | ||
|
||
received_no=$(fgrep operational out/mosquitto.sub | jq -r .system.serial_no) | ||
|
||
if [[ $received_no != $serial_no ]]; then | ||
echo Mismatched/missing serial no: $received_no != $serial_no | ||
false | ||
fi | ||
|
||
echo Done with mosquitto pubber check. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we can't do this kind of stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which kind of stuff, exactly?