diff --git a/Jenkinsfile b/Jenkinsfile index 9e7fd296e072829cb48546a5427df60b37b9d774..bc5c2126859b097e85291d5d26ba38156c55e375 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,6 +30,9 @@ pipeline { if (body.contains("[smoke only]")) { env.smokeOnly = "true" } + if (body.contains("[all logs]")) { + env.getLogs = "all" + } } } } @@ -163,7 +166,7 @@ def RunIntegrationTest(k, v) { export PATH="/tmp/rook-tests-scripts-helm/linux-amd64:$PATH" \ KUBECONFIG=$HOME/admin.conf kubectl config view - _output/tests/linux_amd64/integration -test.v -test.timeout 1800s -test.run SmokeSuite --host_type '''+"${k}"+''' --helm /tmp/rook-tests-scripts-helm/linux-amd64/helm 2>&1 | tee _output/tests/integrationTests.log''' + _output/tests/linux_amd64/integration -test.v -test.timeout 1800s -test.run SmokeSuite --host_type '''+"${k}"+''' --logs '''+"${env.getLogs}"+''' --helm /tmp/rook-tests-scripts-helm/linux-amd64/helm 2>&1 | tee _output/tests/integrationTests.log''' } else { echo "Running full regression" @@ -172,7 +175,7 @@ def RunIntegrationTest(k, v) { export PATH="/tmp/rook-tests-scripts-helm/linux-amd64:$PATH" \ KUBECONFIG=$HOME/admin.conf kubectl config view - _output/tests/linux_amd64/integration -test.v -test.timeout 7200s --host_type '''+"${k}"+''' --helm /tmp/rook-tests-scripts-helm/linux-amd64/helm 2>&1 | tee _output/tests/integrationTests.log''' + _output/tests/linux_amd64/integration -test.v -test.timeout 7200s --host_type '''+"${k}"+''' --logs '''+"${env.getLogs}"+''' --helm /tmp/rook-tests-scripts-helm/linux-amd64/helm 2>&1 | tee _output/tests/integrationTests.log''' } } finally{ diff --git a/tests/framework/installer/cassandra_installer.go b/tests/framework/installer/cassandra_installer.go index 00e10021f61ae5dae27c28b88457049e6439cf17..8f7679e8b4eae506930be7c1443aa7498e598d71 100644 --- a/tests/framework/installer/cassandra_installer.go +++ b/tests/framework/installer/cassandra_installer.go @@ -162,7 +162,12 @@ func (ci *CassandraInstaller) UninstallCassandra(systemNamespace string, namespa } func (ci *CassandraInstaller) GatherAllCassandraLogs(systemNamespace, namespace, testName string) { - + if !ci.T().Failed() && Env.Logs != "all" { + return + } else if ci.T().Failed() { + GatherCRDObjectDebuggingInfo(ci.k8sHelper, systemNamespace) + GatherCRDObjectDebuggingInfo(ci.k8sHelper, namespace) + } logger.Infof("Gathering all logs from Cassandra Cluster %s", namespace) ci.k8sHelper.GetLogs("rook-cassandra-operator", Env.HostType, systemNamespace, testName) ci.k8sHelper.GetLogs("rook-cassandra", Env.HostType, namespace, testName) diff --git a/tests/framework/installer/ceph_installer.go b/tests/framework/installer/ceph_installer.go index 27623d6aa01b4041eec991f7cf8228e0c69afca4..a3d568c4d5761d15f53c229300d992d6ec5b3ffd 100644 --- a/tests/framework/installer/ceph_installer.go +++ b/tests/framework/installer/ceph_installer.go @@ -484,6 +484,9 @@ func (h *CephInstaller) cleanupDir(node, dir string) error { } func (h *CephInstaller) GatherAllRookLogs(namespace, systemNamespace string, testName string) { + if !h.T().Failed() && Env.Logs != "all" { + return + } logger.Infof("Gathering all logs from Rook Cluster %s", namespace) h.k8shelper.GetPreviousLogs("rook-ceph-operator", Env.HostType, systemNamespace, testName) h.k8shelper.GetLogs("rook-ceph-operator", Env.HostType, systemNamespace, testName) diff --git a/tests/framework/installer/cockroachdb_installer.go b/tests/framework/installer/cockroachdb_installer.go index f61c068e9fa182056ed84606eab1bc3927cdebda..734e2258a788847e71fc9ba09ea21b4292dc0de5 100644 --- a/tests/framework/installer/cockroachdb_installer.go +++ b/tests/framework/installer/cockroachdb_installer.go @@ -150,6 +150,12 @@ func (h *CockroachDBInstaller) UninstallCockroachDB(systemNamespace, namespace s } func (h *CockroachDBInstaller) GatherAllCockroachDBLogs(systemNamespace, namespace, testName string) { + if !h.T().Failed() && Env.Logs != "all" { + return + } else if h.T().Failed() { + GatherCRDObjectDebuggingInfo(h.k8shelper, systemNamespace) + GatherCRDObjectDebuggingInfo(h.k8shelper, namespace) + } logger.Infof("Gathering all logs from cockroachdb cluster %s", namespace) h.k8shelper.GetLogs("rook-cockroachdb-operator", Env.HostType, systemNamespace, testName) h.k8shelper.GetLogs("rook-cockroachdb", Env.HostType, namespace, testName) diff --git a/tests/framework/installer/edgefs_installer.go b/tests/framework/installer/edgefs_installer.go index c441e70d2c315c65e7a476b6bb3a3ef737477fb1..d8006ca26b255874c33e2306f1e48c0a3bd849f3 100644 --- a/tests/framework/installer/edgefs_installer.go +++ b/tests/framework/installer/edgefs_installer.go @@ -152,6 +152,12 @@ func (h *EdgefsInstaller) UninstallEdgefs(systemNamespace, namespace string) { } func (h *EdgefsInstaller) GatherAllEdgefsLogs(systemNamespace, namespace, testName string) { + if !h.T().Failed() && Env.Logs != "all" { + return + } else if h.T().Failed() { + GatherCRDObjectDebuggingInfo(h.k8shelper, systemNamespace) + GatherCRDObjectDebuggingInfo(h.k8shelper, namespace) + } logger.Infof("Gathering all logs from edgefs cluster %s", namespace) h.k8shelper.GetLogs("rook-edgefs-operator", Env.HostType, systemNamespace, testName) h.k8shelper.GetLogs("rook-edgefs", Env.HostType, namespace, testName) diff --git a/tests/framework/installer/environment.go b/tests/framework/installer/environment.go index ba122905da35ec2b02835619d1730f123c3ff75b..52b425f88307ae2aeaafbc0d7b217e47383180da 100644 --- a/tests/framework/installer/environment.go +++ b/tests/framework/installer/environment.go @@ -32,6 +32,7 @@ type EnvironmentManifest struct { LoadTime int LoadSize string EnableChaos bool + Logs string } var Env EnvironmentManifest @@ -48,4 +49,5 @@ func init() { flag.IntVar(&Env.LoadTime, "load_time", 1800, "number of seconds each thread perform operations for") flag.StringVar(&Env.LoadSize, "load_size", "medium", "load size for each thread performing operations - small,medium or large.") flag.BoolVar(&Env.EnableChaos, "enable_chaos", false, "used to determine if random pods in a namespace are to be killed during load test.") + flag.StringVar(&Env.Logs, "logs", "", "Gather rook logs, eg - all") } diff --git a/tests/framework/installer/nfs_installer.go b/tests/framework/installer/nfs_installer.go index e8537ebfb47bfbdab69097d2ead9c3ce1ee02a2c..1925e02277a6bcc433b6e3c7d742a649242899bc 100644 --- a/tests/framework/installer/nfs_installer.go +++ b/tests/framework/installer/nfs_installer.go @@ -190,6 +190,12 @@ func (h *NFSInstaller) UninstallNFSServer(systemNamespace, namespace string) { // GatherAllNFSServerLogs gathers all NFS Server logs func (h *NFSInstaller) GatherAllNFSServerLogs(systemNamespace, namespace, testName string) { + if !h.T().Failed() && Env.Logs != "all" { + return + } else if h.T().Failed() { + GatherCRDObjectDebuggingInfo(h.k8shelper, systemNamespace) + GatherCRDObjectDebuggingInfo(h.k8shelper, namespace) + } logger.Infof("Gathering all logs from NFSServer %s", namespace) h.k8shelper.GetLogs("rook-nfs-operator", Env.HostType, systemNamespace, testName) h.k8shelper.GetLogs("rook-nfs", Env.HostType, namespace, testName) diff --git a/tests/framework/utils/k8s_helper.go b/tests/framework/utils/k8s_helper.go index c98a051e7d3c1e38b361bc46346a10f010e4201f..6fdbdfdddff49d2ce077398dde973f9d7597f84c 100644 --- a/tests/framework/utils/k8s_helper.go +++ b/tests/framework/utils/k8s_helper.go @@ -33,7 +33,7 @@ import ( "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/util/exec" "github.com/stretchr/testify/require" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/tests/integration/base_deploy_test.go b/tests/integration/base_deploy_test.go index f2a7473dda903a8e9c9e7b1b0e951317c4ce0f57..17f5161118ee228f1b1d7e2fa255e9805b64f284 100644 --- a/tests/integration/base_deploy_test.go +++ b/tests/integration/base_deploy_test.go @@ -140,8 +140,6 @@ func (op *TestCluster) SetInstallData(version string) {} // TearDownRook is a wrapper for tearDown after Suite func (op *TestCluster) Teardown() { - if op.installer.T().Failed() { - op.installer.GatherAllRookLogs(op.namespace, installer.SystemNamespace(op.namespace), op.installer.T().Name()) - } + op.installer.GatherAllRookLogs(op.namespace, installer.SystemNamespace(op.namespace), op.installer.T().Name()) op.installer.UninstallRook(op.namespace) } diff --git a/tests/integration/block_create_test.go b/tests/integration/block_create_test.go index 8ca874d37a52a9838e3acb962c26fb03bb207fd6..894b846a447b5c41db22459b7076d97d19da9690 100644 --- a/tests/integration/block_create_test.go +++ b/tests/integration/block_create_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/tests/integration/cassandra_test.go b/tests/integration/cassandra_test.go index 589f7921e90cc4812669f6a4d278ce61c51b61b0..76d519b59d583ea56c1fa1f94c5b0756fa757402 100644 --- a/tests/integration/cassandra_test.go +++ b/tests/integration/cassandra_test.go @@ -18,16 +18,17 @@ package integration import ( "fmt" + "strconv" + "strings" + "testing" + "time" + cassandrav1alpha1 "github.com/rook/rook/pkg/apis/cassandra.rook.io/v1alpha1" "github.com/rook/rook/tests/framework/installer" "github.com/rook/rook/tests/framework/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "strconv" - "strings" - "testing" - "time" ) // ************************************************ @@ -128,13 +129,7 @@ func (s *CassandraSuite) TestCassandraClusterCreation() { // Teardown gathers logs and other helping info and then uninstalls // everything installed by the CassandraSuite func (s *CassandraSuite) Teardown() { - - if s.T().Failed() { - installer.GatherCRDObjectDebuggingInfo(s.k8sHelper, s.systemNamespace) - installer.GatherCRDObjectDebuggingInfo(s.k8sHelper, s.namespace) - s.installer.GatherAllCassandraLogs(s.systemNamespace, s.namespace, s.T().Name()) - } - + s.installer.GatherAllCassandraLogs(s.systemNamespace, s.namespace, s.T().Name()) s.installer.UninstallCassandra(s.systemNamespace, s.namespace) } diff --git a/tests/integration/cockroachdb_test.go b/tests/integration/cockroachdb_test.go index a8556298d937296aca67074280d8f991e51e05cd..6fbceb704eefc8b754e9ea125c51f382297d5992 100644 --- a/tests/integration/cockroachdb_test.go +++ b/tests/integration/cockroachdb_test.go @@ -88,11 +88,7 @@ func (suite *CockroachDBSuite) Setup() { } func (suite *CockroachDBSuite) Teardown() { - if suite.T().Failed() { - installer.GatherCRDObjectDebuggingInfo(suite.k8shelper, suite.systemNamespace) - installer.GatherCRDObjectDebuggingInfo(suite.k8shelper, suite.namespace) - suite.installer.GatherAllCockroachDBLogs(suite.systemNamespace, suite.namespace, suite.T().Name()) - } + suite.installer.GatherAllCockroachDBLogs(suite.systemNamespace, suite.namespace, suite.T().Name()) suite.installer.UninstallCockroachDB(suite.systemNamespace, suite.namespace) } diff --git a/tests/integration/edgefs_test.go b/tests/integration/edgefs_test.go index df49aaedd6d977aeeadeb59649cd5372a7be19f5..b887f6ef28cac66b68145b3e895842fd8d3507aa 100644 --- a/tests/integration/edgefs_test.go +++ b/tests/integration/edgefs_test.go @@ -83,10 +83,6 @@ func (suite *EdgefsSuite) Setup() { } func (suite *EdgefsSuite) Teardown() { - if suite.T().Failed() { - installer.GatherCRDObjectDebuggingInfo(suite.k8shelper, suite.systemNamespace) - installer.GatherCRDObjectDebuggingInfo(suite.k8shelper, suite.namespace) - } suite.installer.GatherAllEdgefsLogs(suite.systemNamespace, suite.namespace, suite.T().Name()) suite.installer.UninstallEdgefs(suite.systemNamespace, suite.namespace) } diff --git a/tests/integration/multi_cluster_test.go b/tests/integration/multi_cluster_test.go index 04deaf012ef77625955b185b672a28dcb8991647..5c1754008565dbe11b3341e41e642257f1227293 100644 --- a/tests/integration/multi_cluster_test.go +++ b/tests/integration/multi_cluster_test.go @@ -177,10 +177,9 @@ func (o MCTestOperations) Teardown() { o.T().FailNow() } }() - if o.T().Failed() { - o.installer.GatherAllRookLogs(o.namespace1, o.systemNamespace, o.T().Name()) - o.installer.GatherAllRookLogs(o.namespace2, o.systemNamespace, o.T().Name()) - } + + o.installer.GatherAllRookLogs(o.namespace1, o.systemNamespace, o.T().Name()) + o.installer.GatherAllRookLogs(o.namespace2, o.systemNamespace, o.T().Name()) o.installer.UninstallRookFromMultipleNS(installer.SystemNamespace(o.namespace1), o.namespace1, o.namespace2) } diff --git a/tests/integration/nfs_test.go b/tests/integration/nfs_test.go index c0b0f334c9a0fe3215fc19b7e88a25e7a0ba6b38..d7b25978c641ee0fbce60f50330a41bbe67f89db 100644 --- a/tests/integration/nfs_test.go +++ b/tests/integration/nfs_test.go @@ -89,11 +89,7 @@ func (suite *NfsSuite) Setup() { } func (suite *NfsSuite) Teardown() { - if suite.T().Failed() { - installer.GatherCRDObjectDebuggingInfo(suite.k8shelper, suite.systemNamespace) - installer.GatherCRDObjectDebuggingInfo(suite.k8shelper, suite.namespace) - suite.installer.GatherAllNFSServerLogs(suite.systemNamespace, suite.namespace, suite.T().Name()) - } + suite.installer.GatherAllNFSServerLogs(suite.systemNamespace, suite.namespace, suite.T().Name()) suite.installer.UninstallNFSServer(suite.systemNamespace, suite.namespace) }