Statistics
| Branch: | Tag: | Revision:

root / devel / check-split-query @ ab6536ba

History | View | Annotate | Download (2.2 kB)

1 63fb3de0 Iustin Pop
#!/bin/bash
2 63fb3de0 Iustin Pop
3 63fb3de0 Iustin Pop
# Copyright (C) 2013 Google Inc.
4 63fb3de0 Iustin Pop
#
5 63fb3de0 Iustin Pop
# This program is free software; you can redistribute it and/or modify
6 63fb3de0 Iustin Pop
# it under the terms of the GNU General Public License as published by
7 63fb3de0 Iustin Pop
# the Free Software Foundation; either version 2 of the License, or
8 63fb3de0 Iustin Pop
# (at your option) any later version.
9 63fb3de0 Iustin Pop
#
10 63fb3de0 Iustin Pop
# This program is distributed in the hope that it will be useful, but
11 63fb3de0 Iustin Pop
# WITHOUT ANY WARRANTY; without even the implied warranty of
12 63fb3de0 Iustin Pop
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 63fb3de0 Iustin Pop
# General Public License for more details.
14 63fb3de0 Iustin Pop
#
15 63fb3de0 Iustin Pop
# You should have received a copy of the GNU General Public License
16 63fb3de0 Iustin Pop
# along with this program; if not, write to the Free Software
17 63fb3de0 Iustin Pop
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 63fb3de0 Iustin Pop
# 02110-1301, USA.
19 63fb3de0 Iustin Pop
20 63fb3de0 Iustin Pop
# Checks query equivalence between masterd and confd
21 63fb3de0 Iustin Pop
#
22 63fb3de0 Iustin Pop
# This is not (currently) run automatically during QA, but you can run
23 63fb3de0 Iustin Pop
# it manually on a test cluster. It will force all queries known to be
24 63fb3de0 Iustin Pop
# converted via both paths and check the difference, via both 'list'
25 63fb3de0 Iustin Pop
# and 'list-fields'. For best results, it should be run on a non-empty
26 63fb3de0 Iustin Pop
# cluster.
27 63fb3de0 Iustin Pop
#
28 63fb3de0 Iustin Pop
# Also note that this is not expected to show 100% perfect matches,
29 63fb3de0 Iustin Pop
# since the JSON output differs slightly for complex data types
30 63fb3de0 Iustin Pop
# (e.g. dictionaries with different sort order for keys, etc.).
31 63fb3de0 Iustin Pop
#
32 63fb3de0 Iustin Pop
# Current known delta:
33 63fb3de0 Iustin Pop
# - all dicts, sort order
34 63fb3de0 Iustin Pop
# - ctime is always defined in Haskell as epoch 0 if missing
35 63fb3de0 Iustin Pop
36 63fb3de0 Iustin Pop
MA=`mktemp master.XXXXXX`
37 63fb3de0 Iustin Pop
CF=`mktemp confd.XXXXXX`
38 63fb3de0 Iustin Pop
trap 'rm -f "$MA" "$CF"' EXIT
39 63fb3de0 Iustin Pop
trap 'exit 1' SIGINT
40 63fb3de0 Iustin Pop
41 63fb3de0 Iustin Pop
RET=0
42 63fb3de0 Iustin Pop
SEP="--separator=,"
43 63fb3de0 Iustin Pop
ENABLED_QUERIES="node group network backup"
44 63fb3de0 Iustin Pop
45 63fb3de0 Iustin Pop
test_cmd() {
46 63fb3de0 Iustin Pop
  cmd="$1"
47 63fb3de0 Iustin Pop
  desc="$2"
48 63fb3de0 Iustin Pop
  FORCE_LUXI_SOCKET=master $cmd > "$MA"
49 63fb3de0 Iustin Pop
  FORCE_LUXI_SOCKET=query  $cmd > "$CF"
50 63fb3de0 Iustin Pop
  diff -u "$MA" "$CF" || {
51 63fb3de0 Iustin Pop
    echo "Mismatch in $desc, see above."
52 63fb3de0 Iustin Pop
    RET=1
53 63fb3de0 Iustin Pop
  }
54 63fb3de0 Iustin Pop
}
55 63fb3de0 Iustin Pop
56 63fb3de0 Iustin Pop
for kind in $ENABLED_QUERIES; do
57 63fb3de0 Iustin Pop
  all_fields=$(FORCE_LUXI_SOCKET=master gnt-$kind list-fields \
58 63fb3de0 Iustin Pop
    --no-headers --separator=,|cut -d, -f1)
59 63fb3de0 Iustin Pop
  comma_fields=$(echo $all_fields|tr ' ' ,|sed -e 's/,$//')
60 63fb3de0 Iustin Pop
  for op in list list-fields; do
61 63fb3de0 Iustin Pop
    test_cmd "gnt-$kind $op $SEP" "$kind $op"
62 63fb3de0 Iustin Pop
  done
63 63fb3de0 Iustin Pop
  #test_cmd "gnt-$kind list $SEP -o$comma_fields" "$kind list with all fields"
64 63fb3de0 Iustin Pop
  for field in $all_fields; do
65 63fb3de0 Iustin Pop
    test_cmd "gnt-$kind list $SEP -o$field" "$kind list for field $field"
66 63fb3de0 Iustin Pop
  done
67 63fb3de0 Iustin Pop
done
68 63fb3de0 Iustin Pop
69 63fb3de0 Iustin Pop
exit $RET