From 5c2b28091f6a75e56182eb8cbb77d69f1a9063b4 Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Tue, 24 Nov 2020 17:17:18 -0600
Subject: [PATCH] Add some basic checks for tile gen/mapserver/mapcache

---
 ci_tests/run_basic_grb_test.sh | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/ci_tests/run_basic_grb_test.sh b/ci_tests/run_basic_grb_test.sh
index b781136..1838882 100755
--- a/ci_tests/run_basic_grb_test.sh
+++ b/ci_tests/run_basic_grb_test.sh
@@ -100,20 +100,43 @@ run_geo2grid_checks() {
 }
 
 run_tile_gen_checks() {
+    count=0
+    while true; do
+      num_files=$(kubectl exec -n $ns ${TILEGEN_POD_NAME} -- ls -1 /dst/tiles/g16/abi/radm1/*/*.shp | wc -l || echo 0)
+      let count=count+1
+      if [[ $num_files -gt 16 ]]; then
+          debug "Got at least 16 files ($num_files)"
+          break
+      fi
+      if [[ $count -gt 10 ]]; then
+          error "Took too long for Geo2Grid to produce files ($num_files so far)"
+      fi
+      debug "Found $num_files files, waiting for more..."
+      sleep 10
+    done
     return 0
 }
 
 run_mapserver_checks() {
-    return 0
+    # Ex: ["2020-11-24T22:23:19", "2020...
+    # Get the first element without quotes
+    first_time=$(curl -s "http://${MAPSERVER_RELEASE_NAME}.${ns}/wms_times/g16/abi/radm1/C01" | head -c 21 | tail -c 19)
+    # if there aren't any times then we failed
+    if [ $first_time == "" ]; then
+        return 1
+    else
+        return 0
+    fi
 }
 
 run_mapcache_checks() {
-    return 0
+    first_time=$(curl -s "http://${MAPSERVER_RELEASE_NAME}.${ns}/wms_times/g16/abi/radm1/C01" | head -c 21 | tail -c 19)
+    curl -s "https://${MAPCACHE_RELEASE_NAME}.${ns}/mapcache/wmts/?TIME=${first_time}Z&TILEMATRIXSET=grid_g16_abi_radf_1000m&LAYER=g16_abi_radf_l1b_C01&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=0&TileCol=0&TileRow=0" > /dev/null
 }
 
 run_client_checks() {
     # just try to load the webpage at all
-    curl -s "http://${CLIENT_RELEASE_NAME}.${ns}/"
+    curl -s "http://${CLIENT_RELEASE_NAME}.${ns}/" >/dev/null
 }
 set -e
 
-- 
GitLab