Ver código fonte

peer: update shadow test

Justin Tracey 10 meses atrás
pai
commit
687e841036
1 arquivos alterados com 12 adições e 3 exclusões
  1. 12 3
      shadow/peer/run.sh

+ 12 - 3
shadow/peer/run.sh

@@ -1,7 +1,7 @@
 #!/bin/bash
 
 rm -rf shadow.data/
-shadow --template-directory shadow.data.template shadow.yaml > shadow.log
+shadow --pcap-enabled true --template-directory shadow.data.template shadow.yaml > shadow.log
 ret=$?
 
 declare -A groups
@@ -9,7 +9,7 @@ groups[group1]="Alice Bob Carol"
 groups[group2]="Alice Bob Dave"
 
 check_one_log() {
-    counts="$(grep -Ec "$1" shadow.data/hosts/*/*.stdout | cut -d: -f2 | sort -n)"
+    counts="$(grep -Ec "$1" shadow.data/hosts/peer*/*.stdout | cut -d: -f2 | sort -n)"
     if [[ $(echo "$counts" | tail -1) -lt $2 ]] ; then
         echo "Not enough matches of pattern: $1"
         ret=1
@@ -21,13 +21,20 @@ check_one_log() {
 }
 
 check_all_logs() {
-    counts="$(grep -Ec "$1" shadow.data/hosts/*/*.stdout | cut -d: -f2 | sort -n)"
+    counts="$(grep -Ec "$1" shadow.data/hosts/peer*/*.stdout | cut -d: -f2 | sort -n)"
     if [[ $(echo "$counts" | tail -1) -lt $2 ]] ; then
         echo "Not enough matches of pattern: $1"
         ret=1
     fi
 }
 
+invert_check_all_logs() {
+    if grep -Eq "$1" shadow.data/hosts/peer*/*.stdout ; then
+        echo "Found errors via pattern: $1"
+        ret=1
+    fi
+}
+
 for group in ${!groups[@]} ; do
     for name in ${groups[$group]} ; do
         echo "$group,$name"
@@ -41,6 +48,8 @@ for group in ${!groups[@]} ; do
         check_one_log "$name,$group,receive,.*,[0-9]+" 10
         # users got at least 10 normal messages from this user in this group
         check_all_logs "$group,receive,.*,$name,[0-9]+" 10
+        # users didn't get any errors
+        invert_check_all_logs "[Ee]rr"
     done
 done