diff --git a/Jenkinsfile b/Jenkinsfile index 9e7fd296e..bc5c21268 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 00e10021f..8f7679e8b 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 27623d6aa..a3d568c4d 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 f61c068e9..734e2258a 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 c441e70d2..d8006ca26 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 ba122905d..52b425f88 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 e8537ebfb..1925e0227 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 c98a051e7..6fdbdfddd 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/block_create_test.go b/tests/integration/block_create_test.go index 8ca874d37..894b846a4 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 a19d1d637..76d519b59 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,12 +129,6 @@ 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.UninstallCassandra(s.systemNamespace, s.namespace) } diff --git a/tests/integration/cockroachdb_test.go b/tests/integration/cockroachdb_test.go index 901242349..6fbceb704 100644 --- a/tests/integration/cockroachdb_test.go +++ b/tests/integration/cockroachdb_test.go @@ -88,10 +88,6 @@ 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.UninstallCockroachDB(suite.systemNamespace, suite.namespace) } diff --git a/tests/integration/edgefs_test.go b/tests/integration/edgefs_test.go index df49aaedd..b887f6ef2 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/nfs_test.go b/tests/integration/nfs_test.go index ebf198c66..d7b25978c 100644 --- a/tests/integration/nfs_test.go +++ b/tests/integration/nfs_test.go @@ -89,10 +89,6 @@ 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.UninstallNFSServer(suite.systemNamespace, suite.namespace) }