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