1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
From: Reinhard Tartler <siretart@tauware.de>
Date: Wed, 7 Aug 2024 07:30:47 -0400
Subject: tolerate absence of 'netavark' binary in tests
---
buildah_test.go | 4 ++++
cmd/buildah/common_test.go | 4 ++++
commit_test.go | 4 ++++
common_test.go | 4 ++++
convertcw_test.go | 4 ++++
5 files changed, 20 insertions(+)
diff --git a/buildah_test.go b/buildah_test.go
index d019aba..7a7d416 100644
--- a/buildah_test.go
+++ b/buildah_test.go
@@ -4,6 +4,7 @@ import (
"context"
"flag"
"os"
+ "strings"
"testing"
imagetypes "github.com/containers/image/v5/types"
@@ -52,6 +53,9 @@ func TestOpenBuilderCommonBuildOpts(t *testing.T) {
require.NoError(t, err)
t.Cleanup(func() { _, err := store.Shutdown(true); assert.NoError(t, err) })
b, err := NewBuilder(ctx, store, BuilderOptions{})
+ if strings.Contains(err.Error(), "netavark") {
+ t.Skipf("Cannot execute, failed to construct builder: %v", err)
+ }
require.NoError(t, err)
require.NotNil(t, b.CommonBuildOpts)
b.CommonBuildOpts = nil
diff --git a/cmd/buildah/common_test.go b/cmd/buildah/common_test.go
index 3fc7a5f..98aec62 100644
--- a/cmd/buildah/common_test.go
+++ b/cmd/buildah/common_test.go
@@ -2,6 +2,7 @@ package main
import (
"flag"
+ "strings"
"os"
"os/user"
"testing"
@@ -128,6 +129,9 @@ func pullTestImage(t *testing.T) string {
b, err := buildah.NewBuilder(getContext(), store, options)
if err != nil {
+ if strings.Contains(err.Error(), "netavark") {
+ t.Skipf("Ignoring test setup related error: %s", err)
+ }
t.Fatal(err)
}
id := b.FromImageID
diff --git a/commit_test.go b/commit_test.go
index 96f540e..f473c54 100644
--- a/commit_test.go
+++ b/commit_test.go
@@ -8,6 +8,7 @@ import (
"io"
"os"
"path/filepath"
+ "strings"
"testing"
"time"
@@ -85,6 +86,9 @@ func TestCommitLinkedLayers(t *testing.T) {
SystemContext: &testSystemContext,
}
b, err := NewBuilder(ctx, store, builderOptions)
+ if strings.Contains(err.Error(), "netavark") {
+ t.Skipf("Skipping test: %v", err)
+ }
require.NoError(t, err, "creating builder")
b.SetCreatedBy(imageName(layerNumber))
firstFile := makeFile("file0", 0)
diff --git a/common_test.go b/common_test.go
index e4ba179..78a0cfe 100644
--- a/common_test.go
+++ b/common_test.go
@@ -7,6 +7,7 @@ import (
"encoding/json"
"os"
"path/filepath"
+ "strings"
"testing"
"time"
@@ -144,6 +145,9 @@ func TestRetryCopyImage(t *testing.T) {
require.NoError(t, policyContext.Destroy(), "destroying policy context")
})
_, err = retryCopyImage(ctx, policyContext, destRef, srcRef, destRef, &cp.Options{}, 3, 1*time.Second)
+ if strings.Contains(err.Error(), "operation not permitted") {
+ t.Skipf("Skipping test: %v", err)
+ }
require.NoError(t, err, "copying image")
_, err = retryCopyImage(ctx, policyContext, destRef, srcRef, destRef, &cp.Options{}, 3, 1*time.Second)
require.NoError(t, err, "copying image")
diff --git a/convertcw_test.go b/convertcw_test.go
index a6fb860..b01faab 100644
--- a/convertcw_test.go
+++ b/convertcw_test.go
@@ -12,6 +12,7 @@ import (
"os"
"path/filepath"
"sync"
+ "strings"
"testing"
"github.com/containers/buildah/internal/mkcw"
@@ -119,6 +120,9 @@ func TestCWConvertImage(t *testing.T) {
return
}
if ignoreChainRetrievalErrors && ignoreAttestationErrors {
+ if strings.Contains(err.Error(), "netavark") {
+ t.Skipf("Test setup failed: %v", err)
+ }
assert.NoError(t, err)
}
if err != nil {
|