weldr: update depsolve calls in weldr API
Update the weldr API to work with the new depsolve API. Update tests to match (adding repo_id). Co-authored-by: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
dab836de19
commit
e8a0e8ff49
4 changed files with 189 additions and 85 deletions
|
|
@ -140,11 +140,13 @@ func createTestWeldrAPI(tempdir, hostDistroName, hostArchName string, fixtureGen
|
|||
// For packages, it uses the dnfjson_mock.BaseDeps() every time, but retains
|
||||
// the map keys from the input.
|
||||
// For ostree commits it hashes the URL+Ref to create a checksum.
|
||||
func ResolveContent(pkgs map[string][]rpmmd.PackageSet, containers map[string][]container.SourceSpec, commits map[string][]ostree.SourceSpec) (map[string][]rpmmd.PackageSpec, map[string][]container.Spec, map[string][]ostree.CommitSpec) {
|
||||
func ResolveContent(pkgs map[string][]rpmmd.PackageSet, containers map[string][]container.SourceSpec, commits map[string][]ostree.SourceSpec) (map[string]dnfjson.DepsolveResult, map[string][]container.Spec, map[string][]ostree.CommitSpec) {
|
||||
|
||||
pkgSpecs := make(map[string][]rpmmd.PackageSpec, len(pkgs))
|
||||
depsolved := make(map[string]dnfjson.DepsolveResult, len(pkgs))
|
||||
for name := range pkgs {
|
||||
pkgSpecs[name] = dnfjson_mock.BaseDeps()
|
||||
depsolved[name] = dnfjson.DepsolveResult{
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
}
|
||||
|
||||
containerSpecs := make(map[string][]container.Spec, len(containers))
|
||||
|
|
@ -172,7 +174,7 @@ func ResolveContent(pkgs map[string][]rpmmd.PackageSet, containers map[string][]
|
|||
}
|
||||
}
|
||||
|
||||
return pkgSpecs, containerSpecs, commitSpecs
|
||||
return depsolved, containerSpecs, commitSpecs
|
||||
}
|
||||
|
||||
func TestBasic(t *testing.T) {
|
||||
|
|
@ -1048,6 +1050,8 @@ func TestCompose(t *testing.T) {
|
|||
},
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
addRepoID(expectedComposeLocal.Packages, "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e")
|
||||
|
||||
expectedComposeLocalAndAws := &store.Compose{
|
||||
Blueprint: &blueprint.Blueprint{
|
||||
Name: "test",
|
||||
|
|
@ -1093,6 +1097,8 @@ func TestCompose(t *testing.T) {
|
|||
},
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
addRepoID(expectedComposeLocalAndAws.Packages, "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e")
|
||||
|
||||
expectedComposeOSTree := &store.Compose{
|
||||
Blueprint: &blueprint.Blueprint{
|
||||
Name: "test",
|
||||
|
|
@ -1121,6 +1127,7 @@ func TestCompose(t *testing.T) {
|
|||
},
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
addRepoID(expectedComposeOSTree.Packages, "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e")
|
||||
|
||||
ostreeOptionsOther := ostree.ImageOptions{ImageRef: otherRef, URL: ostreeRepoOther.Server.URL}
|
||||
ostreeManifestOther, _, err := ostreeImgType.Manifest(nil, distro.ImageOptions{OSTree: &ostreeOptionsOther}, nil, nil)
|
||||
|
|
@ -1158,6 +1165,7 @@ func TestCompose(t *testing.T) {
|
|||
},
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
addRepoID(expectedComposeOSTreeOther.Packages, "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e")
|
||||
|
||||
// For 2nd distribution
|
||||
distro2 := test_distro.DistroFactory(testDistro2Name)
|
||||
|
|
@ -1202,6 +1210,7 @@ func TestCompose(t *testing.T) {
|
|||
},
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
addRepoID(expectedComposeGoodDistro.Packages, "0a99a351a0031411571ddfacc8a131862cfc389d5516400d0cdbc9340a6ec423")
|
||||
|
||||
var cases = map[string]struct {
|
||||
External bool
|
||||
|
|
@ -1996,8 +2005,8 @@ func TestProjectsDepsolve(t *testing.T) {
|
|||
ExpectedJSON string
|
||||
}{
|
||||
{rpmmd_mock.NonExistingPackage, "/api/v0/projects/depsolve/fash", http.StatusBadRequest, `{"status":false,"errors":[{"id":"ProjectsError","msg":"BadRequest: running osbuild-depsolve-dnf failed:\nDNF error occurred: MarkingErrors: Error occurred when marking packages for installation: Problems in request:\nmissing packages: fash"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "/api/v0/projects/depsolve/fish", http.StatusOK, `{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","check_gpg":true, "checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","check_gpg":true, "checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","check_gpg":true, "checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "/api/v0/projects/depsolve/fish?distro=test-distro-2", http.StatusOK, `{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","check_gpg":true, "checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","check_gpg":true, "checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","check_gpg":true, "checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "/api/v0/projects/depsolve/fish", http.StatusOK, `{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720","check_gpg":true,"repo_id":"ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893","check_gpg":true,"repo_id":"ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2","check_gpg":true,"repo_id":"ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "/api/v0/projects/depsolve/fish?distro=test-distro-2", http.StatusOK, `{"projects":[{"name":"dep-package3","epoch":7,"version":"3.0.3","release":"1.fc30","arch":"x86_64","checksum":"sha256:62278d360aa5045eb202af39fe85743a4b5615f0c9c7439a04d75d785db4c720","check_gpg":true,"repo_id":"0a99a351a0031411571ddfacc8a131862cfc389d5516400d0cdbc9340a6ec423"},{"name":"dep-package1","epoch":0,"version":"1.33","release":"2.fc30","arch":"x86_64","checksum":"sha256:fe3951d112c3b1c84dc8eac57afe0830df72df1ca0096b842f4db5d781189893","check_gpg":true,"repo_id":"0a99a351a0031411571ddfacc8a131862cfc389d5516400d0cdbc9340a6ec423"},{"name":"dep-package2","epoch":0,"version":"2.9","release":"1.fc30","arch":"x86_64","checksum":"sha256:5797c0b0489681596b5b3cd7165d49870b85b69d65e08770946380a3dcd49ea2","check_gpg":true,"repo_id":"0a99a351a0031411571ddfacc8a131862cfc389d5516400d0cdbc9340a6ec423"}]}`},
|
||||
{rpmmd_mock.BadDepsolve, "/api/v0/projects/depsolve/go2rpm", http.StatusBadRequest, `{"status":false,"errors":[{"id":"ProjectsError","msg":"BadRequest: running osbuild-depsolve-dnf failed:\nDNF error occurred: DepsolveError: There was a problem depsolving ['go2rpm']: \n Problem: conflicting requests\n - nothing provides askalono-cli needed by go2rpm-1-4.fc31.noarch"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "/api/v0/projects/depsolve/fish?distro=fedora-1", http.StatusBadRequest, `{"status":false,"errors":[{"id":"DistroError","msg":"Invalid distro: fedora-1"}]}`},
|
||||
}
|
||||
|
|
@ -2196,6 +2205,13 @@ func TestComposeTypes_ImageTypeDenylist(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func addRepoID(packages []rpmmd.PackageSpec, id string) {
|
||||
for idx, pkg := range packages {
|
||||
pkg.RepoID = id
|
||||
packages[idx] = pkg
|
||||
}
|
||||
}
|
||||
|
||||
func TestComposePOST_ImageTypeDenylist(t *testing.T) {
|
||||
distro2 := test_distro.DistroFactory(testDistro2Name)
|
||||
require.NotNil(t, distro2)
|
||||
|
|
@ -2240,6 +2256,9 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) {
|
|||
},
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
// the repo ID can't be statically added to the package list because it
|
||||
// changes based on the test repository configuration
|
||||
addRepoID(expectedComposeLocal.Packages, "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e")
|
||||
|
||||
expectedComposeLocal2 := &store.Compose{
|
||||
Blueprint: &blueprint.Blueprint{
|
||||
|
|
@ -2269,6 +2288,7 @@ func TestComposePOST_ImageTypeDenylist(t *testing.T) {
|
|||
},
|
||||
Packages: dnfjson_mock.BaseDeps(),
|
||||
}
|
||||
addRepoID(expectedComposeLocal2.Packages, "ac982f7c76771e898d1112d1a81d182eeb48af4a26792df248ebf6a47de06a4e")
|
||||
|
||||
var cases = []struct {
|
||||
Path string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue