Skip to content

Commit 0f425cd

Browse files
committed
e2e: skip if mg version less than 4.22
We don't want this test to run on older version because we don't have the selinux data which in older MG, which means the test is gonna failed. Signed-off-by: Talor Itzhak <titzhak@redhat.com>
1 parent 72d9e43 commit 0f425cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/e2e/must-gather/must_gather_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/opencontainers/selinux/go-selinux"
3131

3232
corev1 "k8s.io/api/core/v1"
33+
"k8s.io/apimachinery/pkg/util/version"
3334
"k8s.io/klog/v2"
3435

3536
"sigs.k8s.io/yaml"
@@ -190,6 +191,8 @@ var _ = Describe("[must-gather] NRO data collected", func() {
190191
})
191192

192193
It("check SELinux data files have been collected", func(ctx context.Context) {
194+
minVersion := version.MustParse("4.21")
195+
193196
destDirContent, err := os.ReadDir(destDir)
194197
Expect(err).NotTo(HaveOccurred(), "unable to read contents from destDir:%s. error: %w", destDir, err)
195198

@@ -199,6 +202,16 @@ var _ = Describe("[must-gather] NRO data collected", func() {
199202
}
200203
mgContentFolder := filepath.Join(destDir, content.Name())
201204

205+
mgVersionData, err := os.ReadFile(filepath.Join(mgContentFolder, "version"))
206+
Expect(err).ToNot(HaveOccurred(), "failed to read must-gather version file")
207+
mgVersionLines := strings.Split(strings.TrimSpace(string(mgVersionData)), "\n")
208+
Expect(len(mgVersionLines)).To(BeNumerically(">=", 2), "must-gather version file should have at least 2 lines")
209+
mgVersion, err := version.Parse(mgVersionLines[1])
210+
Expect(err).ToNot(HaveOccurred(), "failed to parse must-gather version: %s", mgVersionLines[1])
211+
if mgVersion.LessThan(minVersion) {
212+
Skip(fmt.Sprintf("SELinux data collection is only supported on must-gather version %s or newer, got %s", minVersion, mgVersion))
213+
}
214+
202215
By(fmt.Sprintf("Checking Folder: %q", mgContentFolder))
203216
By("Looking for SELinux info directory")
204217

0 commit comments

Comments
 (0)