Commit d6f63166 authored by Santosh Pillai's avatar Santosh Pillai
Browse files

Optionally collect all CI logs using [all logs] flag

Signed-off-by: default avatarSantosh Pillai <sapillai@redhat.com>
Showing with 48 additions and 37 deletions
+48 -37
......@@ -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{
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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")
}
......@@ -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)
......
......@@ -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"
......
......@@ -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)
}
......@@ -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"
)
......
......@@ -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)
}
......
......@@ -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)
}
......
......@@ -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)
}
......
......@@ -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)
}
......
......@@ -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)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment