Skip to content

Commit d497442

Browse files
committed
.github,test: Upload container logs during e2e runs as artifacts (#2432)
* test/e2e: Update operators v1 API package import name Update the operatorsv1 API package import from v1 -> operatorsv1. Signed-off-by: timflannagan <[email protected]> * .github,test/e2e: Specify a base testing artifacts directory Update the $JUNIT_DIRECTORY environment varaible that's used throughout the e2e testing suite to the more generalized $ARTIFACTS_DIRECTORY which can be used as the base directory for various testing artifacts. + downstream only change to prevent openshift-ci from breaking from the change in environment variable Junit reports are now created implicitly whenever the $ARTIFACTS_DIRECTORY has been specified/non-empty. Signed-off-by: timflannagan <[email protected]> * test/e2e: Collect container logs in the kind provisioner before deprovisioning Update the kind provisioner and collect container logs (and various other testing artifacts) before deprovisioning the kind cluster that tests were running. Signed-off-by: timflannagan <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: 58c8485b2ac3001b9b44fabb9369bae5362087d4
1 parent a0b989b commit d497442

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/setup-go@v2
1515
with:
1616
go-version: '~1.16'
17-
- run: make e2e-local E2E_NODES=2 JUNIT_DIRECTORY=./artifacts/
17+
- run: make e2e-local E2E_NODES=2 ARTIFACTS_DIR=./artifacts/
1818
- name: Archive Test Artifacts # test results, failed or not, are always uploaded.
1919
if: ${{ always() }}
2020
uses: actions/upload-artifact@v2

staging/operator-lifecycle-manager/test/e2e/ctx/provisioner_kind.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
var (
2424
images = flag.String("kind.images", "", "comma-separated list of image archives to load on cluster nodes, relative to the test binary or test package path")
25+
logDir = "logs"
2526

2627
verbosity int
2728
)
@@ -139,6 +140,12 @@ func Provision(ctx *TestContext) (func(), error) {
139140
var once sync.Once
140141
deprovision := func() {
141142
once.Do(func() {
143+
if artifactsDir := os.Getenv("ARTIFACTS_DIR"); artifactsDir != "" {
144+
ctx.Logf("collecting container logs for the %s cluster", name)
145+
if err := provider.CollectLogs(name, filepath.Join(artifactsDir, logDir)); err != nil {
146+
ctx.Logf("failed to collect logs: %v", err)
147+
}
148+
}
142149
provider.Delete(name, kubeconfigPath)
143150
})
144151
}

staging/operator-lifecycle-manager/test/e2e/e2e_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1717
"sigs.k8s.io/controller-runtime/pkg/client"
1818

19-
v1 "github.com/operator-framework/api/pkg/operators/v1"
19+
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
2020
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
2121
)
2222

@@ -43,6 +43,7 @@ var (
4343
testNamespace = ""
4444
operatorNamespace = ""
4545
communityOperatorsImage = ""
46+
junitDir = "junit"
4647
)
4748

4849
func TestEndToEnd(t *testing.T) {
@@ -52,7 +53,11 @@ func TestEndToEnd(t *testing.T) {
5253
SetDefaultConsistentlyDuration(30 * time.Second)
5354
SetDefaultConsistentlyPollingInterval(1 * time.Second)
5455

55-
if junitDir := os.Getenv("JUNIT_DIRECTORY"); junitDir != "" {
56+
// always configure a junit report when ARTIFACTS_DIR has been set
57+
if artifactsDir := os.Getenv("ARTIFACTS_DIR"); artifactsDir != "" {
58+
junitReporter := reporters.NewJUnitReporter(path.Join(artifactsDir, junitDir, fmt.Sprintf("junit_e2e_%02d.xml", config.GinkgoConfig.ParallelNode)))
59+
RunSpecsWithDefaultAndCustomReporters(t, "End-to-end", []Reporter{junitReporter})
60+
} else if junitDir := os.Getenv("JUNIT_DIRECTORY"); junitDir != "" { // Downstream-only legacy requirement
5661
junitReporter := reporters.NewJUnitReporter(path.Join(junitDir, fmt.Sprintf("junit_e2e_%02d.xml", config.GinkgoConfig.ParallelNode)))
5762
RunSpecsWithDefaultAndCustomReporters(t, "End-to-end", []Reporter{junitReporter})
5863
} else {
@@ -75,10 +80,10 @@ var _ = BeforeSuite(func() {
7580
deprovision = ctx.MustProvision(ctx.Ctx())
7681
ctx.MustInstall(ctx.Ctx())
7782

78-
var groups v1.OperatorGroupList
83+
var groups operatorsv1.OperatorGroupList
7984
Expect(ctx.Ctx().Client().List(context.Background(), &groups, client.InNamespace(testNamespace))).To(Succeed())
8085
if len(groups.Items) == 0 {
81-
og := v1.OperatorGroup{
86+
og := operatorsv1.OperatorGroup{
8287
ObjectMeta: metav1.ObjectMeta{
8388
Name: "opgroup",
8489
Namespace: testNamespace,
@@ -88,12 +93,12 @@ var _ = BeforeSuite(func() {
8893
}
8994

9095
// Tests can assume the group in the test namespace has been reconciled at least once.
91-
Eventually(func() ([]v1.OperatorGroupStatus, error) {
92-
var groups v1.OperatorGroupList
96+
Eventually(func() ([]operatorsv1.OperatorGroupStatus, error) {
97+
var groups operatorsv1.OperatorGroupList
9398
if err := ctx.Ctx().Client().List(context.Background(), &groups, client.InNamespace(testNamespace)); err != nil {
9499
return nil, err
95100
}
96-
var statuses []v1.OperatorGroupStatus
101+
var statuses []operatorsv1.OperatorGroupStatus
97102
for _, group := range groups.Items {
98103
statuses = append(statuses, group.Status)
99104
}

0 commit comments

Comments
 (0)