From fd81dd11a0ac310f380fa684e66b8b36fc0fd4ca Mon Sep 17 00:00:00 2001 From: Santosh Pillai Date: Thu, 2 May 2019 14:40:43 +0530 Subject: [PATCH 1/2] reverted commit - 185909604196eb79b00e97ec662ebf2a6cf1119b Signed-off-by: Santosh Pillai --- tests/integration/base_deploy_test.go | 4 +++- tests/integration/cassandra_test.go | 2 +- tests/integration/cockroachdb_test.go | 2 +- tests/integration/multi_cluster_test.go | 7 ++++--- tests/integration/nfs_test.go | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/integration/base_deploy_test.go b/tests/integration/base_deploy_test.go index 17f516111..f2a7473dd 100644 --- a/tests/integration/base_deploy_test.go +++ b/tests/integration/base_deploy_test.go @@ -140,6 +140,8 @@ func (op *TestCluster) SetInstallData(version string) {} // TearDownRook is a wrapper for tearDown after Suite func (op *TestCluster) Teardown() { - op.installer.GatherAllRookLogs(op.namespace, installer.SystemNamespace(op.namespace), op.installer.T().Name()) + if op.installer.T().Failed() { + op.installer.GatherAllRookLogs(op.namespace, installer.SystemNamespace(op.namespace), op.installer.T().Name()) + } op.installer.UninstallRook(op.namespace) } diff --git a/tests/integration/cassandra_test.go b/tests/integration/cassandra_test.go index a19d1d637..589f7921e 100644 --- a/tests/integration/cassandra_test.go +++ b/tests/integration/cassandra_test.go @@ -132,9 +132,9 @@ 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 901242349..a8556298d 100644 --- a/tests/integration/cockroachdb_test.go +++ b/tests/integration/cockroachdb_test.go @@ -91,8 +91,8 @@ 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/multi_cluster_test.go b/tests/integration/multi_cluster_test.go index 5c1754008..04deaf012 100644 --- a/tests/integration/multi_cluster_test.go +++ b/tests/integration/multi_cluster_test.go @@ -177,9 +177,10 @@ func (o MCTestOperations) Teardown() { o.T().FailNow() } }() - - o.installer.GatherAllRookLogs(o.namespace1, o.systemNamespace, o.T().Name()) - o.installer.GatherAllRookLogs(o.namespace2, o.systemNamespace, o.T().Name()) + 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.UninstallRookFromMultipleNS(installer.SystemNamespace(o.namespace1), o.namespace1, o.namespace2) } diff --git a/tests/integration/nfs_test.go b/tests/integration/nfs_test.go index ebf198c66..c0b0f334c 100644 --- a/tests/integration/nfs_test.go +++ b/tests/integration/nfs_test.go @@ -92,8 +92,8 @@ 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) } From d6f63166a043988811f5893209cc64b6ce5799f4 Mon Sep 17 00:00:00 2001 From: Santosh Pillai Date: Thu, 2 May 2019 17:55:01 +0530 Subject: [PATCH 2/2] Optionally collect all CI logs using [all logs] flag Signed-off-by: Santosh Pillai --- Jenkinsfile | 7 +++++-- .../framework/installer/cassandra_installer.go | 7 ++++++- tests/framework/installer/ceph_installer.go | 3 +++ .../installer/cockroachdb_installer.go | 6 ++++++ tests/framework/installer/edgefs_installer.go | 6 ++++++ tests/framework/installer/environment.go | 2 ++ tests/framework/installer/nfs_installer.go | 6 ++++++ tests/framework/utils/k8s_helper.go | 2 +- tests/integration/base_deploy_test.go | 4 +--- tests/integration/block_create_test.go | 2 +- tests/integration/cassandra_test.go | 17 ++++++----------- tests/integration/cockroachdb_test.go | 6 +----- tests/integration/edgefs_test.go | 4 ---- tests/integration/multi_cluster_test.go | 7 +++---- tests/integration/nfs_test.go | 6 +----- 15 files changed, 48 insertions(+), 37 deletions(-) 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/base_deploy_test.go b/tests/integration/base_deploy_test.go index f2a7473dd..17f516111 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 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 589f7921e..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,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 a8556298d..6fbceb704 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 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/multi_cluster_test.go b/tests/integration/multi_cluster_test.go index 04deaf012..5c1754008 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 c0b0f334c..d7b25978c 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) }