Skip to content

Commit

Permalink
test: weldr api module_hotfixes flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ezr-ondrej authored and bcl committed May 10, 2024
1 parent c886d6c commit 41b13a6
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
59 changes: 59 additions & 0 deletions internal/client/blueprints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"encoding/json"
"fmt"
"os/exec"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -1006,6 +1007,64 @@ func TestBlueprintDepsolveGlobsV0(t *testing.T) {
assert.True(t, common.IsStringInSortedSlice(names, "tmux"))
}

// depsolve a blueprint with package from 3rd party with module_hotfixes
func TestBlueprintDepsolveModuleHotfixesV0(t *testing.T) {
// Depends on real packages, only run as an integration test
if testState.unitTest {
t.Skip()
}
var repo string
switch runtime.GOARCH {
case "amd64":
repo = "https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-x86_64-nginx-20231207"
case "arm64":
repo = "https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-aarch64-nginx-20231207"
default:
// We don't know how to test for another architectures :)
t.Skip()
}

source := fmt.Sprintf(`{
"id": "nginx",
"name": "nginx disabled modularity filtering",
"url": "%s",
"type": "yum-baseurl",
"check_gpg": true,
"gpgkeys": ["https://nginx.org/keys/nginx_signing.key"],
"module_hotfixes": true
}`, repo)

respSource, err := PostJSONSourceV1(testState.socket, source)
require.NoError(t, err, "POST source failed with a client error")
require.True(t, respSource.Status, "POST blueprint failed: %#v", respSource)

bp := `{
"name": "test-deps-blueprint-module-hotfixes-v0",
"description": "CheckBlueprintDepsolveModuleHotfixesV0",
"version": "0.0.1",
"packages": [{"name": "nginx", "version": "*"},
{"name": "nginx-module-njs", "version": "*"}]
}`
t.Log(bp)

// Push a blueprint
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)

// Depsolve the blueprint
deps, api, err := DepsolveBlueprintV0(testState.socket, "test-deps-blueprint-module-hotfixes-v0")
require.NoError(t, err, "Depsolve blueprint failed with a client error")
require.Nil(t, api, "DepsolveBlueprint failed: %#v", api)
require.Equal(t, 0, len(deps.Errors), "Errors occurred during depsolving")
require.Greater(t, len(deps.Blueprints), 0, "No blueprint dependencies returned")

// cleanup the repo
resp, err = DeleteSourceV1(testState.socket, "nginx")
require.NoError(t, err, "DELETE source failed with a client error")
require.True(t, resp.Status, "DELETE source failed: %#v", resp)
}

// depsolve a non-existent blueprint
func TestNonBlueprintDepsolveV0(t *testing.T) {
resp, api, err := DepsolveBlueprintV0(testState.socket, "test-deps-non-blueprint-v0")
Expand Down
12 changes: 12 additions & 0 deletions internal/weldr/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func (s SourceConfigV0) SourceConfig() (ssc store.SourceConfig) {
ssc.URL = s.URL
ssc.CheckGPG = s.CheckGPG
ssc.CheckSSL = s.CheckSSL
if s.ModuleHotfixes != nil {
modHotfixesVal := *s.ModuleHotfixes
ssc.ModuleHotfixes = &modHotfixesVal
}

return ssc
}
Expand All @@ -196,6 +200,10 @@ func NewSourceConfigV1(id string, s store.SourceConfig) SourceConfigV1 {
sc.RHSM = s.RHSM
sc.CheckRepoGPG = s.CheckRepoGPG
sc.GPGKeys = s.GPGKeys
if s.ModuleHotfixes != nil {
modHotfixesVal := *s.ModuleHotfixes
sc.ModuleHotfixes = &modHotfixesVal
}

return sc
}
Expand Down Expand Up @@ -244,6 +252,10 @@ func (s SourceConfigV1) SourceConfig() (ssc store.SourceConfig) {
ssc.RHSM = s.RHSM
ssc.CheckRepoGPG = s.CheckRepoGPG
ssc.GPGKeys = s.GPGKeys
if s.ModuleHotfixes != nil {
modHotfixesVal := *s.ModuleHotfixes
ssc.ModuleHotfixes = &modHotfixesVal
}

return ssc
}
Expand Down

0 comments on commit 41b13a6

Please sign in to comment.