summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/sasl_fed
blob: 884c44177ca586cf656bc8f144ef156ae3d125df (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#! /bin/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.
#

source ./test_env.sh

# This minimum value corresponds to sasl version 2.1.22
minimum_sasl_version=131350

sasl_version=`$QPID_TEST_EXEC_DIR/sasl_version`

# This test is necessary becasue this sasl version is the first one that permits 
# redirection of the sasl config file path.
if [ "$sasl_version" -lt  "$minimum_sasl_version" ]; then
  echo "sasl_fed: must have sasl version 2.1.22 or greater.  ( Integer value: $minimum_sasl_version )  Version is: $sasl_version"
  exit 0
fi

# In a distribution, the python tools will be absent.
if [ ! -f $QPID_CONFIG_EXEC ] || [ ! -f $QPID_ROUTE_EXEC ] ; then
    echo "python tools absent - skipping sasl_fed."
    exit 0
fi


sasl_config_file=$builddir/sasl_config

my_random_number=$RANDOM
tmp_root=/tmp/sasl_fed_$my_random_number
mkdir -p $tmp_root


#--------------------------------------------------
#echo " Starting broker 1"
#--------------------------------------------------
$QPIDD_EXEC                                  \
  -p 0                                       \
  --data-dir $tmp_root/data_1                \
  --auth=yes                                 \
  --mgmt-enable=yes                          \
  --log-enable info+                         \
  --log-source yes                           \
  --log-to-file $tmp_root/qpidd_1.log        \
  --sasl-config=$sasl_config_file            \
  -d > $tmp_root/broker_1_port

broker_1_port=`cat $tmp_root/broker_1_port`


#--------------------------------------------------
#echo " Starting broker 2"
#--------------------------------------------------
$QPIDD_EXEC                                  \
  -p 0                                       \
  --data-dir $tmp_root/data_2                \
  --auth=yes                                 \
  --mgmt-enable=yes                          \
  --log-enable info+                         \
  --log-source yes                           \
  --log-to-file $tmp_root/qpidd_2.log        \
  --sasl-config=$sasl_config_file            \
  -d > $tmp_root/broker_2_port

broker_2_port=`cat $tmp_root/broker_2_port`

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 "  add exchanges"
#--------------------------------------------------
$QPID_CONFIG_EXEC -a localhost:$broker_1_port add exchange direct $EXCHANGE_NAME
$QPID_CONFIG_EXEC -a localhost:$broker_2_port add exchange direct $EXCHANGE_NAME


#--------------------------------------------------
#echo "  add queues"
#--------------------------------------------------
$QPID_CONFIG_EXEC -a localhost:$broker_1_port add queue $QUEUE_NAME
$QPID_CONFIG_EXEC -a localhost:$broker_2_port add queue $QUEUE_NAME

sleep 5

#--------------------------------------------------
#echo " create bindings"
#--------------------------------------------------
$QPID_CONFIG_EXEC -a localhost:$broker_1_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY
$QPID_CONFIG_EXEC -a localhost:$broker_2_port bind $EXCHANGE_NAME $QUEUE_NAME $ROUTING_KEY

sleep 5


#--------------------------------------------------
#echo "  qpid-route route add"
#--------------------------------------------------
$QPID_ROUTE_EXEC 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 "
#--------------------------------------------------
$builddir/datagen --count $n_messages | $SENDER_EXEC --mechanism DIGEST-MD5 --username zag --password zag --exchange $EXCHANGE_NAME --routing-key $ROUTING_KEY --port $broker_1_port

sleep 5

#--------------------------------------------------
#echo "  Examine Broker $broker_1_port"
#--------------------------------------------------
broker_1_message_count=`$PYTHON_COMMANDS/qpid-stat -q localhost:$broker_1_port | grep sasl_fed_queue | awk '{print $2}'`
#echo " "

#--------------------------------------------------
#echo "  Examine Broker $broker_2_port"
#--------------------------------------------------
broker_2_message_count=`$PYTHON_COMMANDS/qpid-stat -q localhost:$broker_2_port | grep sasl_fed_queue | awk '{print $2}'`
#echo " "

#--------------------------------------------------
#echo "  Asking brokers to quit."
#--------------------------------------------------
$QPIDD_EXEC --port $broker_1_port --quit
$QPIDD_EXEC --port $broker_2_port --quit


#--------------------------------------------------
#echo   "Removing temporary directory $tmp_root"
#--------------------------------------------------
rm -rf $tmp_root

if [ "$broker_2_message_count" -eq  "$n_messages" ]; then
  # echo "good: |$broker_2_message_count| == |$n_messages|"
  exit 0
else
  # echo "not ideal: |$broker_1_message_count| != |$n_messages|"
  exit 1
fi