File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed
testing/kuttl/e2e/support-export Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package cmd
1717import (
1818 "archive/tar"
1919 "bytes"
20+ "compress/gzip"
2021 "context"
2122 "fmt"
2223 "io"
@@ -226,18 +227,25 @@ kubectl pgo support export daisy --monitoring-namespace another-namespace --outp
226227 }
227228
228229 // Name file with year-month-day-HrMinSecTimezone suffix
229- // Example: crunchy_k8s_support_export_2022-08-08-115726-0400.tar
230- outputFile := "crunchy_k8s_support_export_" + time .Now ().Format ("2006-01-02-150405-0700" ) + ".tar"
230+ // Example: crunchy_k8s_support_export_2022-08-08-115726-0400.tar.gz
231+ outputFile := "crunchy_k8s_support_export_" + time .Now ().Format ("2006-01-02-150405-0700" ) + ".tar.gz "
231232 // #nosec G304 -- We intentionally write to the directory supplied by the user.
232233 tarFile , err := os .Create (outputDir + "/" + outputFile )
233234 if err != nil {
234235 return err
235236 }
236237
237- tw := tar .NewWriter (tarFile )
238+ gw , err := gzip .NewWriterLevel (tarFile , gzip .BestCompression )
239+ if err != nil {
240+ return err
241+ }
242+ tw := tar .NewWriter (gw )
238243 defer func () {
239244 // ignore any errors from Close functions, the writers will be
240245 // closed when the program exits
246+ if gw != nil {
247+ _ = gw .Close ()
248+ }
241249 if tw != nil {
242250 _ = tw .Close ()
243251 }
Original file line number Diff line number Diff line change @@ -3,14 +3,23 @@ apiVersion: kuttl.dev/v1beta1
33kind : TestStep
44commands :
55- script : kubectl-pgo --namespace $NAMESPACE support export kuttl-support-cluster -o .
6- - script : tar -xf ./crunchy_k8s_support_export_*.tar
6+ - script : tar -xf ./crunchy_k8s_support_export_*.tar.gz
77- script : |
88 #!/bin/bash
99
1010 DIR="./kuttl-support-cluster/nodes/"
1111 LIST="${DIR}list"
1212
13- CLEANUP="rm -r ./kuttl-support-cluster ./crunchy_k8s_support_export_*.tar"
13+ CLEANUP="rm -r ./kuttl-support-cluster ./crunchy_k8s_support_export_*.tar.gz"
14+
15+ # check for expected gzip compression level
16+ FILE_INFO=$(file ./crunchy_k8s_support_export_*.tar.gz)
17+ [[ "${FILE_INFO}" == *'gzip compressed data, max compression'* ]] || {
18+ echo "Expected gzip max compression message, got:"
19+ echo "${FILE_INFO}"
20+ eval "$CLEANUP"
21+ exit 1
22+ }
1423
1524 # check for expected table header in the list file
1625 KV=$(awk 'NR==1 {print $9}' $LIST)
@@ -50,4 +59,4 @@ commands:
5059 exit 1
5160 fi
5261
53- - script : rm -r ./kuttl-support-cluster ./crunchy_k8s_support_export_*.tar
62+ - script : rm -r ./kuttl-support-cluster ./crunchy_k8s_support_export_*.tar.gz
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ apiVersion: kuttl.dev/v1beta1
33kind : TestStep
44commands :
55- script : kubectl-pgo --namespace $NAMESPACE support export kuttl-support-monitoring-cluster -o .
6- - script : tar -xf ./crunchy_k8s_support_export_*.tar
6+ - script : tar -xf ./crunchy_k8s_support_export_*.tar.gz
77- script : |
88 #!/bin/bash
99
10- CLEANUP="rm -r ./kuttl-support-monitoring-cluster ./monitoring ./crunchy_k8s_support_export_*.tar"
10+ CLEANUP="rm -r ./kuttl-support-monitoring-cluster ./monitoring ./crunchy_k8s_support_export_*.tar.gz "
1111 CLUSTER_DIR="./kuttl-support-monitoring-cluster/logs/"
1212 MONITORING_DIR="./monitoring/logs/"
1313
@@ -40,4 +40,4 @@ commands:
4040 exit 1
4141 fi
4242
43- - script : rm -r ./kuttl-support-monitoring-cluster ./monitoring ./crunchy_k8s_support_export_*.tar
43+ - script : rm -r ./kuttl-support-monitoring-cluster ./monitoring ./crunchy_k8s_support_export_*.tar.gz
You can’t perform that action at this time.
0 commit comments