summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/sasl_fed
blob: 8491d428be0fc50656c3f43d86dbb59c0a4e99c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash

#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
# 
#   http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

set -eu

WORK_DIR=$WORK_DIR/sasl_fed
mkdir $WORK_DIR

sasl_config_dir=$BUILD_DIR/src/tests/sasl_config

# Create ACL file to allow links
echo acl allow all all > $WORK_DIR/sasl_fed.acl

echo "Starting broker 1"

qpidd                                        \
  -p 0  --interface 127.0.0.1                \
  --data-dir $WORK_DIR/data_1                \
  --auth=yes                                 \
  --mgmt-enable=yes                          \
  --log-enable info+                         \
  --log-source yes                           \
  --log-to-file $WORK_DIR/qpidd_1.log        \
  --sasl-config=$sasl_config_dir             \
  --acl-file $WORK_DIR/sasl_fed.acl          \
  -d > $WORK_DIR/broker_1_port

broker_1_port=$(cat $WORK_DIR/broker_1_port)

echo "Starting broker 2"

qpidd                                        \
  -p 0 --interface 127.0.0.1                 \
  --data-dir $WORK_DIR/data_2                \
  --auth=yes                                 \
  --mgmt-enable=yes                          \
  --log-enable info+                         \
  --log-source yes                           \
  --log-to-file $WORK_DIR/qpidd_2.log        \
  --sasl-config=$sasl_config_dir             \
  --acl-file $WORK_DIR/sasl_fed.acl          \
  -d > $WORK_DIR/broker_2_port

broker_2_port=$(cat $WORK_DIR/broker_2_port)

function stop_brokers {
    qpidd --port $broker_1_port --quit
    qpidd --port $broker_2_port --quit
}

trap stop_brokers EXIT

sleep 2

# I am not randomizing these names, because the test creates its own brokers.
QUEUE_NAME=sasl_fed_queue
ROUTING_KEY=sasl_fed_queue
EXCHANGE_NAME=sasl_fedex

echo "Adding exchanges"

qpid-config -b localhost:$broker_1_port add exchange direct $EXCHANGE_NAME
qpid-config -b localhost:$broker_2_port add exchange direct $EXCHANGE_NAME

echo "Adding queues"

qpid-config -b localhost:$broker_1_port add queue $QUEUE_NAME
qpid-config -b localhost:$broker_2_port add queue $QUEUE_NAME

sleep 5

echo "Creating bindings"

qpid-config -b localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
qpid-config -b localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY

sleep 5

echo "Adding routes"

qpid-route route add zag/zag@localhost:$broker_2_port zag/zag@localhost:$broker_1_port $EXCHANGE_NAME $ROUTING_KEY "" "" DIGEST-MD5

sleep 5

n_messages=100

echo "Sending 100 messages to $broker_1_port "

datagen --count $n_messages | sender --mechanism DIGEST-MD5 --username zag --password zag --exchange $EXCHANGE_NAME --routing-key $ROUTING_KEY --port $broker_1_port

sleep 5

echo "Examining Broker $broker_1_port"

broker_1_message_count=$(qpid-stat -q -b localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}')

echo "Examining Broker $broker_2_port"

broker_2_message_count=$(qpid-stat -q -b localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}')

if (( $broker_2_message_count != $n_messages )); then
    echo "Expected ${n_messages} and received ${broker_2_message_count}"
    exit 1
fi