Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

amqp_trx_plugin - transaction in, transaction_trace out #9181

Merged
merged 67 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
bb48710
WIP: initial outline of rabbitmq_trx_plugin
heifner May 18, 2020
96d520e
WIP: first cut at publish
heifner May 18, 2020
176d598
WIP: Add publish of drop of trx"
heifner May 18, 2020
b8654a2
WIP: Adding support to cleos
heifner May 19, 2020
d5e591d
Merge remote-tracking branch 'origin/develop' into rabbitmq-trx-dev
heifner May 22, 2020
a5d81c1
Simplify unpacking of message
heifner May 22, 2020
5e27754
Change logging and add quit() on error
heifner May 22, 2020
2b1f167
Add simple support for trx/trace rabbitmq
heifner May 22, 2020
3abc4dd
Merge remote-tracking branch 'origin/develop' into rabbitmq-trx-dev
heifner May 26, 2020
08e4a4f
Make rabbitmq exchange configurable
heifner May 26, 2020
ee0bb75
Implement rabbitmq_publish_all_traces option
heifner May 26, 2020
5627b0a
Use nomenclature AMQP instead of RabbitMQ
heifner May 27, 2020
a5b3f02
Add ability to test with rabbitmq
heifner May 28, 2020
36ca869
destroy amqp before thread_pool to fix crash. ack consumed traces.
heifner May 29, 2020
1e7d097
Better shutdown logic
heifner May 29, 2020
7d28362
Add integration test for rabbitmq
heifner May 29, 2020
d94fac9
Merge remote-tracking branch 'origin/develop' into rabbitmq-trx-dev
heifner May 29, 2020
5080366
Add new amqp_trx logger to example logging.json
heifner May 29, 2020
1be90c7
Turn on debug level logging for launcher for trace_api and ampq_trx l…
heifner May 29, 2020
dc19fed
Add support for empty "" default value
heifner May 29, 2020
ef410ef
Revert "Merge pull request #9134 from EOSIO/test-framework-archiving"
heifner May 29, 2020
f8116cc
Revert "Revert "Merge pull request #9134 from EOSIO/test-framework-ar…
heifner Jun 1, 2020
0dd804d
Populate amqp connection string and conditionally run rabbitmq test
parrinc Jun 3, 2020
8a4b06d
Merge branch 'develop-boxed' into rabbitmq-trx-dev
heifner Jun 4, 2020
754a9ee
Merge branch 'develop-boxed' into rabbitmq-trx-dev
heifner Jun 5, 2020
ef104ae
Drain application queue before disconnecting from transction singal
heifner Jun 5, 2020
299f841
Re-work shutdown logic
heifner Jun 5, 2020
e7a4d16
Don't ack message as other consumers may be interested in the trace
heifner Jun 5, 2020
14f08dd
Temp rm app().quit()
heifner Jun 9, 2020
98c993f
Add some info level logging
heifner Jun 10, 2020
7b01617
ioservice for send
heifner Jun 10, 2020
48026b1
Temp logging of publish result
heifner Jun 10, 2020
4cf9c9b
Revert "ioservice for send"
heifner Jun 11, 2020
eb53f95
Add cerr of amqp publish
heifner Jun 11, 2020
4491a8b
Remove debug output
heifner Jun 11, 2020
cd24672
Initial checkin of amqp_trace_plugin
heifner Jun 11, 2020
c662157
Use amqp_trace_plugin for publish of traces. Address peer review comm…
heifner Jun 11, 2020
8c8c24d
Add new amqp_trace_plugin needed for test
heifner Jun 11, 2020
ea3ca24
trx queue
heifner Jun 11, 2020
44f932d
Make amqp_trace_plugin depend on amqp_trx_plugin
heifner Jun 11, 2020
f08bbc2
Correct check for if amqp is in use
heifner Jun 11, 2020
56db06e
Guard agaisnt getting report of trace twice
heifner Jun 11, 2020
9e177e7
Stop thread pool before destroying amqp objects
heifner Jun 12, 2020
7665a7d
Enable debug level logging of default logger
heifner Jun 12, 2020
7420f95
Add extra debug logging
heifner Jun 12, 2020
a2644a8
Use diff thread pool (io_service) for each amqp as mixing causing issues
heifner Jun 12, 2020
0120831
Work around duplicate message handling in amqp integration test
heifner Jun 12, 2020
5d43e92
Fix description
heifner Jun 16, 2020
d18d39b
Move into same scope as eosio::amqp
heifner Jun 16, 2020
b9b43ec
add rabbit to cicd images
Jun 16, 2020
d03eea1
Merge remote-tracking branch 'origin/develop-boxed' into rabbitmq-trx…
heifner Jun 17, 2020
8b46cd0
Check state of amqp_trace_plugin instead of setting up dependency
heifner Jun 17, 2020
381069d
Remove duplicate code amqp_publish_hander
heifner Jun 17, 2020
7e79625
Verify queue ready before returning
heifner Jun 17, 2020
84ffede
Modify cleos with amqp to only submit trx and not try to report trace
heifner Jun 17, 2020
cd28210
Call declare queue on amqp thread
heifner Jun 18, 2020
3f111d3
Use raw promise to avoid race condition
heifner Jun 18, 2020
fc78974
Always startup amqp_trace_plugin before amqp_trx_plugin if specified
heifner Jun 18, 2020
259da4c
Handle shutdown in case of exception
heifner Jun 18, 2020
0de2a11
Use weak ptr to avoid keeping impl alive after shutdown
heifner Jun 18, 2020
f910787
No coordination between http_plugin posted tasks and amqp_trx_plugin …
heifner Jun 18, 2020
bfd69da
Merge remote-tracking branch 'origin/develop-boxed' into rabbitmq-trx…
heifner Jun 19, 2020
6366fe1
Make sure thread_pool is stopped if exception before amqp destroyed
heifner Jun 19, 2020
6b88873
Refactor amqp handler to encapsoluate thread and provide safer interface
heifner Jun 19, 2020
b8f7acb
Merge remote-tracking branch 'origin/develop' into rabbitmq-trx-dev
heifner Jun 19, 2020
aa67fb5
Merge remote-tracking branch 'origin/develop-boxed' into rabbitmq-trx…
heifner Jun 19, 2020
e3c26d3
Peer review changes and fix problem with multiple calls to stop()
heifner Jun 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cicd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eo pipefail
. ./.cicd/helpers/general.sh
mkdir -p $BUILD_DIR
CMAKE_EXTRAS="-DCMAKE_BUILD_TYPE='Release' -DENABLE_MULTIVERSION_PROTOCOL_TEST=true -DENABLE_UNITY_BUILD=ON"
CMAKE_EXTRAS="-DCMAKE_BUILD_TYPE='Release' -DENABLE_MULTIVERSION_PROTOCOL_TEST=true -DENABLE_UNITY_BUILD=ON -DAMQP_CONN_STR='amqp://guest:guest@localhost:5672'"
if [[ "$(uname)" == 'Darwin' && $FORCE_LINUX != true ]]; then
# You can't use chained commands in execute
if [[ "$GITHUB_ACTIONS" == 'true' ]]; then
Expand Down Expand Up @@ -59,4 +59,4 @@ else # Linux
COMMANDS="$PRE_COMMANDS && $COMMANDS"
echo "$ docker run $ARGS $(buildkite-intrinsics) $FULL_TAG bash -c \"$COMMANDS\""
eval docker run $ARGS $(buildkite-intrinsics) $FULL_TAG bash -c \"$COMMANDS\"
fi
fi
7 changes: 6 additions & 1 deletion .cicd/platforms/pinned/amazon_linux-2-pinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ RUN yum update -y && \
libtool make bzip2 bzip2-devel openssl-devel gmp-devel libstdc++ libcurl-devel \
libusbx-devel python3 python3-devel python-devel libedit-devel doxygen \
graphviz patch gcc gcc-c++ vim-common jq
# install erlang and rabbitmq
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash && \
yum install -y erlang
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash && \
yum install -y rabbitmq-server
# build cmake
RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz && \
tar -xzf cmake-3.16.2.tar.gz && \
Expand Down Expand Up @@ -50,4 +55,4 @@ RUN echo 'export NVM_DIR="$HOME/.nvm"' > ~/.bashrc && \
# install node 10
RUN bash -c '. ~/.bashrc; nvm install --lts=dubnium' && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/node" /usr/local/bin/node && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/npm" /usr/local/bin/npm
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/npm" /usr/local/bin/npm
7 changes: 6 additions & 1 deletion .cicd/platforms/pinned/centos-7.7-pinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ RUN yum update -y && \
graphviz bzip2-devel openssl-devel gmp-devel ocaml \
python python-devel rh-python36 file libusbx-devel \
libcurl-devel patch vim-common jq
# install erlang and rabbitmq
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash && \
yum install -y erlang
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash && \
yum install -y rabbitmq-server
# build cmake
RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz && \
tar -xzf cmake-3.16.2.tar.gz && \
Expand Down Expand Up @@ -57,4 +62,4 @@ RUN cp ~/.bashrc ~/.bashrc.bak && \
# install node 10
RUN bash -c '. ~/.bashrc; nvm install --lts=dubnium' && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/node" /usr/local/bin/node
RUN yum install -y nodejs
RUN yum install -y nodejs
6 changes: 4 additions & 2 deletions .cicd/platforms/pinned/macos-10.14-pinned.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eo pipefail
VERSION=1
brew update
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl@1.1 jq || :
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl@1.1 jq rabbitmq || :
# install clang from source
git clone --single-branch --branch llvmorg-10.0.0 https://github.com/llvm/llvm-project clang10
mkdir clang10/build
Expand All @@ -23,4 +23,6 @@ sudo SDKROOT="$SDKROOT" ./b2 --with-iostreams --with-date_time --with-filesystem
cd ..
sudo rm -rf boost_1_72_0.tar.bz2 boost_1_72_0
# install nvm for ship_test
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
# add sbin to path from rabbitmq-server
echo "export PATH=$PATH:/usr/local/sbin" >> ~/.bash_profile
6 changes: 4 additions & 2 deletions .cicd/platforms/pinned/macos-10.15-pinned.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eo pipefail
VERSION=1
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
brew update
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl jq || :
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl jq rabbitmq || :
# install clang from source
git clone --single-branch --branch llvmorg-10.0.0 https://github.com/llvm/llvm-project clang10
mkdir clang10/build
Expand All @@ -22,4 +22,6 @@ sudo -E ./b2 --with-iostreams --with-date_time --with-filesystem --with-system -
cd ..
sudo rm -rf boost_1_72_0.tar.bz2 boost_1_72_0
# install nvm for ship_test
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
# add sbin to path from rabbitmq-server
echo "export PATH=$PATH:/usr/local/sbin" >> ~/.bash_profile
4 changes: 2 additions & 2 deletions .cicd/platforms/pinned/ubuntu-16.04-pinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git automake \
libbz2-dev libssl-dev doxygen graphviz libgmp3-dev autotools-dev \
python2.7 python2.7-dev python3 python3-dev autoconf libtool curl zlib1g-dev \
sudo ruby libusb-1.0-0-dev libcurl4-gnutls-dev pkg-config apt-transport-https vim-common jq
sudo ruby libusb-1.0-0-dev libcurl4-gnutls-dev pkg-config apt-transport-https vim-common jq rabbitmq-server
# build cmake
RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz && \
tar -xzf cmake-3.16.2.tar.gz && \
Expand Down Expand Up @@ -53,4 +53,4 @@ RUN cp ~/.bashrc ~/.bashrc.bak && \
RUN bash -c '. ~/.bashrc; nvm install --lts=dubnium' && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/node" /usr/local/bin/node
RUN curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
RUN sudo apt-get install -y nodejs
RUN sudo apt-get install -y nodejs
4 changes: 2 additions & 2 deletions .cicd/platforms/pinned/ubuntu-18.04-pinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update && \
autotools-dev python2.7 python2.7-dev python3 \
python3-dev python-configparser python-requests python-pip \
autoconf libtool g++ gcc curl zlib1g-dev sudo ruby libusb-1.0-0-dev \
libcurl4-gnutls-dev pkg-config patch vim-common jq
libcurl4-gnutls-dev pkg-config patch vim-common jq rabbitmq-server
# build cmake
RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz && \
tar -xzf cmake-3.16.2.tar.gz && \
Expand Down Expand Up @@ -55,4 +55,4 @@ RUN cp ~/.bashrc ~/.bashrc.bak && \
RUN bash -c '. ~/.bashrc; nvm install --lts=dubnium' && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/node" /usr/local/bin/node
RUN curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
RUN sudo apt-get install -y nodejs
RUN sudo apt-get install -y nodejs
7 changes: 6 additions & 1 deletion .cicd/platforms/unpinned/amazon_linux-2-unpinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ RUN yum update -y && \
libtool make bzip2 bzip2-devel openssl-devel gmp-devel libstdc++ libcurl-devel \
libusbx-devel python3 python3-devel python-devel libedit-devel doxygen \
graphviz clang patch llvm-devel llvm-static vim-common jq
# install erlang and rabbitmq
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash && \
yum install -y erlang
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash && \
yum install -y rabbitmq-server
# build cmake
RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz && \
tar -xzf cmake-3.16.2.tar.gz && \
Expand All @@ -30,4 +35,4 @@ RUN echo 'export NVM_DIR="$HOME/.nvm"' > ~/.bashrc && \
# install node 10
RUN bash -c '. ~/.bashrc; nvm install --lts=dubnium' && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/node" /usr/local/bin/node && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/npm" /usr/local/bin/npm
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/npm" /usr/local/bin/npm
7 changes: 6 additions & 1 deletion .cicd/platforms/unpinned/centos-7.7-unpinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ RUN yum update -y && \
graphviz bzip2-devel openssl-devel gmp-devel ocaml \
python python-devel rh-python36 file libusbx-devel \
libcurl-devel patch vim-common jq llvm-toolset-7.0-llvm-devel llvm-toolset-7.0-llvm-static
# install erlang and rabbitmq
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash && \
yum install -y erlang
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash && \
yum install -y rabbitmq-server
# build cmake
RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz && \
tar -xzf cmake-3.16.2.tar.gz && \
Expand Down Expand Up @@ -38,4 +43,4 @@ RUN cp ~/.bashrc ~/.bashrc.bak && \
# install node 10
RUN bash -c '. ~/.bashrc; nvm install --lts=dubnium' && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/node" /usr/local/bin/node
RUN yum install -y nodejs
RUN yum install -y nodejs
6 changes: 4 additions & 2 deletions .cicd/platforms/unpinned/macos-10.14-unpinned.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
set -eo pipefail
VERSION=1
brew update
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl@1.1 jq boost || :
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl@1.1 jq boost rabbitmq || :
# install nvm for ship_test
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
# add sbin to path from rabbitmq-server
echo "export PATH=$PATH:/usr/local/sbin" >> ~/.bash_profile
6 changes: 4 additions & 2 deletions .cicd/platforms/unpinned/macos-10.15-unpinned.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set -eo pipefail
VERSION=1
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
brew update
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl jq boost || :
brew install git cmake python libtool libusb graphviz automake wget gmp pkgconfig doxygen openssl jq boost rabbitmq || :
# install nvm for ship_test
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
cd ~ && brew install nvm && mkdir -p ~/.nvm && echo "export NVM_DIR=$HOME/.nvm" >> ~/.bash_profile && echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile && cat ~/.bash_profile && source ~/.bash_profile && echo $NVM_DIR && nvm install --lts=dubnium
# add sbin to path from rabbitmq-server
echo "export PATH=$PATH:/usr/local/sbin" >> ~/.bash_profile
4 changes: 2 additions & 2 deletions .cicd/platforms/unpinned/ubuntu-18.04-unpinned.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apt-get update && \
bzip2 automake libbz2-dev libssl-dev doxygen graphviz libgmp3-dev \
autotools-dev python2.7 python2.7-dev python3 python3-dev \
autoconf libtool curl zlib1g-dev sudo ruby libusb-1.0-0-dev \
libcurl4-gnutls-dev pkg-config patch llvm-7-dev clang-7 vim-common jq
libcurl4-gnutls-dev pkg-config patch llvm-7-dev clang-7 vim-common jq rabbitmq-server
# build cmake
RUN curl -LO https://github.com/Kitware/CMake/releases/download/v3.16.2/cmake-3.16.2.tar.gz && \
tar -xzf cmake-3.16.2.tar.gz && \
Expand Down Expand Up @@ -35,4 +35,4 @@ RUN cp ~/.bashrc ~/.bashrc.bak && \
RUN bash -c '. ~/.bashrc; nvm install --lts=dubnium' && \
ln -s "/root/.nvm/versions/node/$(ls -p /root/.nvm/versions/node | sort -Vr | head -1)bin/node" /usr/local/bin/node
RUN curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
RUN sudo apt-get install -y nodejs
RUN sudo apt-get install -y nodejs
6 changes: 3 additions & 3 deletions .cicd/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ set -eo pipefail
# tests
if [[ $(uname) == 'Darwin' ]]; then # macOS
set +e # defer error handling to end
source ~/.bash_profile && ./"$@"
source ~/.bash_profile && rabbitmq-server -detached && sleep 10 && ./"$@"
EXIT_STATUS=$?
else # Linux
COMMANDS="$MOUNTED_DIR/$@"
COMMANDS="rabbitmq-server -detached && sleep 10 && $MOUNTED_DIR/$@"
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile
echo "$ docker run --rm --init -v $(pwd):$MOUNTED_DIR $(buildkite-intrinsics) -e JOBS -e BUILDKITE_API_KEY $FULL_TAG bash -c \"$COMMANDS\""
set +e # defer error handling to end
Expand Down Expand Up @@ -45,4 +45,4 @@ fi
if [[ "$EXIT_STATUS" != 0 ]]; then
echo "Failing due to non-zero exit status from ctest: $EXIT_STATUS"
exit $EXIT_STATUS
fi
fi
2 changes: 2 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ add_subdirectory(db_size_api_plugin)
add_subdirectory(login_plugin)
add_subdirectory(test_control_plugin)
add_subdirectory(test_control_api_plugin)
add_subdirectory(amqp_trx_plugin)
add_subdirectory(amqp_trace_plugin)
add_subdirectory(amqp_witness_plugin)

# Forward variables to top level so packaging picks them up
Expand Down
7 changes: 7 additions & 0 deletions plugins/amqp_trace_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
file(GLOB HEADERS "include/eosio/amqp_trace_plugin/*.hpp")
add_library( amqp_trace_plugin
amqp_trace_plugin.cpp
${HEADERS} )

target_link_libraries( amqp_trace_plugin chain_plugin appbase fc amqpcpp )
target_include_directories( amqp_trace_plugin PUBLIC include )
153 changes: 153 additions & 0 deletions plugins/amqp_trace_plugin/amqp_trace_plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#include <eosio/amqp_trace_plugin/amqp_trace_plugin.hpp>
#include <eosio/amqp_trace_plugin/amqp_handler.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>

#include <eosio/chain/exceptions.hpp>
#include <eosio/chain/transaction.hpp>
#include <eosio/chain/thread_utils.hpp>

#include <boost/signals2/connection.hpp>

namespace {

static appbase::abstract_plugin& amqp_trace_plugin_ = appbase::app().register_plugin<eosio::amqp_trace_plugin>();

} // anonymous

namespace eosio {

using boost::signals2::scoped_connection;

struct amqp_trace_plugin_impl : std::enable_shared_from_this<amqp_trace_plugin_impl> {

// use thread pool even though only one thread currently since it provides simple interface for ioc
std::optional<eosio::chain::named_thread_pool> thread_pool;
std::optional<amqp> amqp_trace;
std::optional<scoped_connection> applied_transaction_connection;

std::string amqp_trace_address;
std::string amqp_trace_exchange;
bool started = false;

public:

// called from any thread
void publish_error( std::string tid, int64_t error_code, std::string error_message ) {
try {
transaction_trace_msg msg{transaction_trace_exception{error_code}};
msg.get<transaction_trace_exception>().error_message = std::move( error_message );
auto buf = fc::raw::pack( msg );
boost::asio::post( thread_pool->get_executor(), [my=shared_from_this(), buf=std::move(buf), tid=std::move(tid)]() {
my->amqp_trace->publish( my->amqp_trace_exchange, tid, buf.data(), buf.size() );
} );
} FC_LOG_AND_DROP()
}

// called on application thread
void on_applied_transaction(const chain::transaction_trace_ptr& trace, const chain::packed_transaction_ptr& t) {
try {
boost::asio::post( thread_pool->get_executor(), [my=shared_from_this(), trace, t]() {
my->publish_result( t, trace );
} );
} FC_LOG_AND_DROP()
}

private:

// called from amqp thread
void publish_result( const chain::packed_transaction_ptr& trx, const chain::transaction_trace_ptr& trace ) {
try {
if( !trace->except ) {
dlog( "chain accepted transaction, bcast ${id}", ("id", trace->id) );
} else {
dlog( "trace except : ${m}", ("m", trace->except->to_string()) );
}
fc::unsigned_int which = transaction_trace_msg::tag<chain::transaction_trace>::value;
uint32_t payload_size = fc::raw::pack_size( which );
payload_size += fc::raw::pack_size( *trace );
std::vector<char> buf( payload_size );
fc::datastream<char*> ds( buf.data(), payload_size );
fc::raw::pack( ds, which );
fc::raw::pack( ds, *trace );
amqp_trace->publish( amqp_trace_exchange, trx->id(), buf.data(), buf.size() );
} FC_LOG_AND_DROP()
}

};

amqp_trace_plugin::amqp_trace_plugin()
: my(std::make_shared<amqp_trace_plugin_impl>()) {}

amqp_trace_plugin::~amqp_trace_plugin() {}

void amqp_trace_plugin::publish_error( std::string tid, int64_t error_code, std::string error_message ) {
my->publish_error( std::move(tid), error_code, std::move(error_message) );
}

void amqp_trace_plugin::set_program_options(options_description& cli, options_description& cfg) {
auto op = cfg.add_options();
op("amqp-trace-address", bpo::value<std::string>(),
"AMQP address: Format: amqp://USER:PASSWORD@ADDRESS:PORT\n"
"Will publish to 'trace' queue.");
op("amqp-trace-exchange", bpo::value<std::string>()->default_value(""),
"Existing AMQP exchange to send transaction trace messages.");
}

void amqp_trace_plugin::plugin_initialize(const variables_map& options) {
try {
EOS_ASSERT( options.count("amqp-trace-address"), chain::plugin_config_exception, "amqp-trace-address required" );
my->amqp_trace_address = options.at("amqp-trace-address").as<std::string>();
my->amqp_trace_exchange = options.at("amqp-trace-exchange").as<std::string>();
}
FC_LOG_AND_RETHROW()
}

void amqp_trace_plugin::plugin_startup() {
if( !my->started ) {
handle_sighup();
try {
ilog( "Starting amqp_trace_plugin" );
my->thread_pool.emplace( "amqp_t", 1 );

my->amqp_trace.emplace( my->thread_pool->get_executor(), my->amqp_trace_address, "trace",
[]( const std::string& err ) {
elog( "amqp error: ${e}", ("e", err) );
app().quit();
} );

auto chain_plug = app().find_plugin<chain_plugin>();
EOS_ASSERT( chain_plug, chain::missing_chain_plugin_exception, "chain_plugin required" );

my->applied_transaction_connection.emplace(
chain_plug->chain().applied_transaction.connect(
[me = my]( std::tuple<const chain::transaction_trace_ptr&, const chain::packed_transaction_ptr&> t ) {
me->on_applied_transaction( std::get<0>( t ), std::get<1>( t ) );
} ) );

my->started = true;
} catch( ... ) {
// always want plugin_shutdown even on exception
plugin_shutdown();
throw;
}
}
}

void amqp_trace_plugin::plugin_shutdown() {
try {
dlog( "shutdown.." );

my->applied_transaction_connection.reset();
if( my->thread_pool ) {
my->thread_pool->stop();
}

dlog( "exit amqp_trace_plugin" );
}
FC_CAPTURE_AND_RETHROW()
}

void amqp_trace_plugin::handle_sighup() {
}

} // namespace eosio
Loading