Skip to content

Commit

Permalink
fix smoketest
Browse files Browse the repository at this point in the history
  • Loading branch information
afiore committed Feb 7, 2019
1 parent 195ee51 commit 4257c08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
13 changes: 7 additions & 6 deletions bin/smoketest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set -e -x
set -e -x -u

rmq_username=test_user
rmq_password=test_password
Expand All @@ -16,12 +16,13 @@ export_dir=/tmp/rmqfwd_exports
es_index=smoketest
es_type=message
rmqfwd_timerange_ops="--since 2010-07-08T09:10:11.012Z --until 2030-07-08T09:10:11.012Z"
rmqfwd_common_ops="--rmq-port 5673 --rmq-creds $rmq_username:$rmq_password --es-index $es_index --es-type $es_type"
rmq_ops="--rmq-port 5673 --rmq-creds $rmq_username:$rmq_password"
es_ops="--es-index $es_index --es-type $es_type"
uuids=()

trap "killall rmqfwd" EXIT
trap "killall rmqfwd" INT
RUST_LOG='rmqfwd=debug' $rmqfwd_bin trace $rmqfwd_common_ops &
RUST_LOG='rmqfwd=debug,hyper=debug' $rmqfwd_bin trace $es_ops $rmq_ops &

if [ ! -f $rmq_admin ]
then
Expand Down Expand Up @@ -64,7 +65,7 @@ i=0
while [ $i -lt 2 ]
do
echo "republishing message with uuid: ${uuids[$i]}"
RUST_LOG='rmqfwd=debug' $rmqfwd_bin republish $rmqfwd_common_ops -b "${uuids[$i]}" -e "publish.$exchange" --target-exchange $other_exchange --target-routing-key $routing_key
RUST_LOG='rmqfwd=debug' $rmqfwd_bin republish $es_ops $rmq_ops -b "${uuids[$i]}" -e "publish.$exchange" --target-exchange $other_exchange --target-routing-key $routing_key
sleep 2
((i+=1))
done
Expand All @@ -80,7 +81,7 @@ fi

# 2. export one single message, checking target directory contains expected file

RUST_LOG=rmqfwd=debug $rmqfwd_bin export $rmqfwd_common_ops -f -p -e "publish.$exchange" -b "${uuids[0]}" $rmqfwd_timerange_ops $export_dir
RUST_LOG=rmqfwd=debug $rmqfwd_bin export $es_ops -f -p -e "publish.$exchange" -b "${uuids[0]}" $rmqfwd_timerange_ops $export_dir
sleep 1
expected=1
file_count=$(find $export_dir -name '*.json' | wc -l)
Expand Down Expand Up @@ -117,7 +118,7 @@ do
ids_ops="$ids_ops --id $id"
done

RUST_LOG=rmqfwd=debug $rmqfwd_bin export $rmqfwd_common_ops $ids_ops -f $export_dir
RUST_LOG=rmqfwd=debug $rmqfwd_bin export $es_ops $ids_ops -f $export_dir
for id in "${ids[@]}"
do
id_file="${export_dir}/$id.json"
Expand Down
6 changes: 3 additions & 3 deletions src/es/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,9 @@ impl MessageStore {

impl MessageSearchService for MessageStore {
// NOTE: what happens when the mappings change?
//
// ES provides a convenient API for that: https://www.elastic.co/guide/en/elasticsearch/reference/2.4/docs-reindex.html
// perhaps this tool should automatically manage migrations by managing two indices at the same time...
//
// TODO: do not create the index if it already exists!
//

fn init_store(&self) -> Task {
use futures::future;
Expand Down Expand Up @@ -364,6 +362,8 @@ impl MessageSearchService for MessageStore {
.body(Body::empty())
.expect("couldn't build a request!");

info!("sending a request: {:?}", req);

Box::new(
http::expect_option::<EsDoc<TimestampedMessage>>(&client, req)
.map(|maybe_doc| (id, maybe_doc.map(|doc| doc._source))),
Expand Down
1 change: 0 additions & 1 deletion src/es/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl TryFrom<Filters> for FilteredQuery {
type Err = Error;

fn try_from(f: Filters) -> Result<Self, Error> {
println!("getting a hashmap");
let hm: HashMap<String, Vec<String>> = f.into();
TryFrom::try_from(hm)
}
Expand Down

0 comments on commit 4257c08

Please sign in to comment.