diff --git a/internal/client/blueprints_non_el10_test.go b/internal/client/blueprints_non_el10_test.go new file mode 100644 index 000000000..eec8cca86 --- /dev/null +++ b/internal/client/blueprints_non_el10_test.go @@ -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() + } + }) + } +} diff --git a/internal/client/blueprints_test.go b/internal/client/blueprints_test.go index 2fb35c59e..fbb76fa3f 100644 --- a/internal/client/blueprints_test.go +++ b/internal/client/blueprints_test.go @@ -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 diff --git a/osbuild-composer.spec b/osbuild-composer.spec index 6055bad77..aeb4ae599 100644 --- a/osbuild-composer.spec +++ b/osbuild-composer.spec @@ -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/