Don't run TestMultilibBlueprintDepsolveV0 on el10 / c10s

TestMultilibBlueprintDepsolveV0 unit test relies on 'gsl' package and
the availability of its 32 bit and 64 bit versions in the distribution
repositories. However, the package is no longer available in c10s /
el10. Moreover, there are no 32 bit RPMs in the repositories.
Conditionally compile the test only if 'rhel10' build tag is not
specified. Modify the SPEC file to define 'rhelX' build tag when
compiling tests on RHEL, where X is the major version.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-06-03 20:55:11 +02:00 committed by Tomáš Hozza
parent f9079ae39c
commit 6e3a41ae07
3 changed files with 64 additions and 47 deletions

View file

@ -0,0 +1,60 @@
//go:build !rhel10
package client
import (
"encoding/json"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// When gsl with version * was specified in the blueprint,
// composer depsolved both x86_64 and i686 version of gsl.
// This test case should prevent this from happening.
// gsl is used because it has x86_64 and i686 versions on both RHEL and Fedora.
// Also, gsl-devel package exists, which is not dependant on gsl and shouldn't
// be depsolved.
//
// NB: This test is skipped on RHEL 10 and CentOS 10 because there are no
// i686 packages available in the repositories.
func TestMultilibBlueprintDepsolveV0(t *testing.T) {
if testState.unitTest {
t.Skip()
}
versionStrings := []string{"*", "2.*", ""}
for _, versionString := range versionStrings {
t.Run(versionString, func(t *testing.T) {
bp := `{
"name": "test-multilib-deps-blueprint-v0",
"description": "CheckBlueprintDepsolveV0",
"version": "0.0.1",
"packages": [{"name": "gsl", "version": "` + versionString + `"}]
}`
resp, err := PostJSONBlueprintV0(testState.socket, bp)
require.NoError(t, err, "POST blueprint failed with a client error")
require.True(t, resp.Status, "POST blueprint failed: %#v", resp)
deps, api, err := DepsolveBlueprintV0(testState.socket, "test-multilib-deps-blueprint-v0")
require.NoError(t, err, "Depsolve blueprint failed with a client error")
require.Nil(t, api, "DepsolveBlueprint failed: %#v", api)
gslCount := 0
for _, dep := range deps.Blueprints[0].Dependencies {
if strings.HasPrefix(dep.Name, "gsl") {
gslCount += 1
}
}
if !assert.Equalf(t, 1, gslCount, "gsl is specified %d-times in the depsolve, should be there only once", gslCount) {
depsolveOutput, err := json.MarshalIndent(deps, "", " ")
require.NoError(t, err)
t.Logf("depsolve output:\n%s", depsolveOutput)
t.FailNow()
}
})
}
}

View file

@ -11,12 +11,10 @@
package client
import (
"encoding/json"
"fmt"
"os/exec"
"sort"
"strconv"
"strings"
"testing"
"github.com/osbuild/osbuild-composer/internal/common"
@ -924,51 +922,6 @@ func TestBlueprintDepsolveV0(t *testing.T) {
}
// When gsl with version * was specified in the blueprint,
// composer depsolved both x86_64 and i686 version of gsl.
// This test case should prevent this from happening.
// gsl is used because it has x86_64 and i686 versions on both RHEL and Fedora.
// Also, gsl-devel package exists, which is not dependant on gsl and shouldn't
// be depsolved.
func TestMultilibBlueprintDepsolveV0(t *testing.T) {
if testState.unitTest {
t.Skip()
}
versionStrings := []string{"*", "2.*", ""}
for _, versionString := range versionStrings {
t.Run(versionString, func(t *testing.T) {
bp := `{
"name": "test-multilib-deps-blueprint-v0",
"description": "CheckBlueprintDepsolveV0",
"version": "0.0.1",
"packages": [{"name": "gsl", "version": "` + versionString + `"}]
}`
resp, err := PostJSONBlueprintV0(testState.socket, bp)
require.NoError(t, err, "POST blueprint failed with a client error")
require.True(t, resp.Status, "POST blueprint failed: %#v", resp)
deps, api, err := DepsolveBlueprintV0(testState.socket, "test-multilib-deps-blueprint-v0")
require.NoError(t, err, "Depsolve blueprint failed with a client error")
require.Nil(t, api, "DepsolveBlueprint failed: %#v", api)
gslCount := 0
for _, dep := range deps.Blueprints[0].Dependencies {
if strings.HasPrefix(dep.Name, "gsl") {
gslCount += 1
}
}
if !assert.Equalf(t, 1, gslCount, "gsl is specified %d-times in the depsolve, should be there only once", gslCount) {
depsolveOutput, err := json.MarshalIndent(deps, "", " ")
require.NoError(t, err)
t.Logf("depsolve output:\n%s", depsolveOutput)
t.FailNow()
}
})
}
}
// depsolve a blueprint with package name glob
func TestBlueprintDepsolveGlobsV0(t *testing.T) {
// Depends on real packages, only run as an integration test

View file

@ -126,6 +126,10 @@ export GOPATH=%{gobuilddir}:%{gopath}
TEST_LDFLAGS="${LDFLAGS:-} -B 0x$(od -N 20 -An -tx1 -w100 /dev/urandom | tr -d ' ')"
%if 0%{?rhel}
GOTAGS="${GOTAGS:+$GOTAGS,}rhel%{rhel}"
%endif
go test -c -tags="integration${GOTAGS:+,$GOTAGS}" -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-composer-cli-tests %{goipath}/cmd/osbuild-composer-cli-tests
go test -c -tags="integration${GOTAGS:+,$GOTAGS}" -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-dnf-json-tests %{goipath}/cmd/osbuild-dnf-json-tests
go test -c -tags="integration${GOTAGS:+,$GOTAGS}" -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-weldr-tests %{goipath}/internal/client/