distro/test: update test distro with new behaviour
Add a checksum as a hash of URL + Ref. Use the parent ref instead of the image ref when it's set. This makes the test distro always behave like ostree commit and container types (image types that can use an ostree parent) and not raw image or installers (that use ostree commits as a payload). Modify the weldr API test with the expected error message.
This commit is contained in:
parent
96b7f05f6f
commit
9ed61d021b
3 changed files with 12 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package distro_test
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
|
@ -167,7 +168,7 @@ func TestImageTypePipelineNames(t *testing.T) {
|
|||
assert.NoError(err)
|
||||
|
||||
containers := make(map[string][]container.Spec, 0)
|
||||
// "resolve" ostree commits by copying the source specs into commit specs
|
||||
|
||||
ostreeSources := m.GetOSTreeSourceSpecs()
|
||||
commits := make(map[string][]ostree.CommitSpec, len(ostreeSources))
|
||||
for name, commitSources := range ostreeSources {
|
||||
|
|
@ -176,7 +177,7 @@ func TestImageTypePipelineNames(t *testing.T) {
|
|||
commitSpecs[idx] = ostree.CommitSpec{
|
||||
Ref: commitSource.Ref,
|
||||
URL: commitSource.URL,
|
||||
Checksum: commitSource.Parent,
|
||||
Checksum: fmt.Sprintf("%x", sha256.Sum256([]byte(commitSource.URL+commitSource.Ref))),
|
||||
}
|
||||
}
|
||||
commits[name] = commitSpecs
|
||||
|
|
|
|||
|
|
@ -245,9 +245,17 @@ func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOpt
|
|||
Ref: defaultRef,
|
||||
}
|
||||
if ostreeOptions := options.OSTree; ostreeOptions != nil {
|
||||
// handle the parameter combo error like we do in distros
|
||||
if ostreeOptions.ParentRef != "" && ostreeOptions.URL == "" {
|
||||
// specifying parent ref also requires URL
|
||||
return nil, nil, ostree.NewParameterComboError("ostree parent ref specified, but no URL to retrieve it")
|
||||
}
|
||||
if ostreeOptions.ImageRef != "" { // override with ref from image options
|
||||
ostreeSource.Ref = ostreeOptions.ImageRef
|
||||
}
|
||||
if ostreeOptions.ParentRef != "" { // override with parent ref
|
||||
ostreeSource.Ref = ostreeOptions.ParentRef
|
||||
}
|
||||
// copy any other options that might be specified
|
||||
ostreeSource.URL = options.OSTree.URL
|
||||
ostreeSource.RHSM = options.OSTree.RHSM
|
||||
|
|
|
|||
|
|
@ -1165,7 +1165,7 @@ func TestCompose(t *testing.T) {
|
|||
"/api/v1/compose",
|
||||
fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"parentid","url":""}}`, test_distro.TestImageTypeOSTree),
|
||||
http.StatusBadRequest,
|
||||
`{"status": false, "errors":[{"id":"OSTreeOptionsError","msg":"ostree parent ref specified, but no URL to retrieve it"}]}`,
|
||||
`{"status": false, "errors":[{"id":"ManifestCreationFailed","msg":"failed to initialize osbuild manifest: ostree parent ref specified, but no URL to retrieve it"}]}`,
|
||||
expectedComposeOSTree,
|
||||
[]string{"build_id", "warnings"},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue