client: test supported and unsupported mountpoints
This commit is contained in:
parent
c671a0dab1
commit
7408be580c
3 changed files with 110 additions and 1 deletions
|
|
@ -451,3 +451,98 @@ func TestFinishedComposeV0(t *testing.T) {
|
|||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
}
|
||||
|
||||
func TestComposeSupportedMountPointV0(t *testing.T) {
|
||||
|
||||
bp := `
|
||||
name="test-compose-supported-mountpoint-v0"
|
||||
description="TestComposeSupportedMountPointV0"
|
||||
version="0.0.1"
|
||||
[[customizations.filesystem]]
|
||||
mountpoint = "/"
|
||||
size = 4294967296
|
||||
`
|
||||
resp, err := PostTOMLBlueprintV0(testState.socket, bp)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.True(t, resp.Status, "POST failed: %#v", resp)
|
||||
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-compose-supported-mountpoint-v0",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`, testState.imageTypeName)
|
||||
|
||||
// Create a finished test compose
|
||||
body, resp, err := PostJSON(testState.socket, "/api/v1/compose?test=2", compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
response, err := NewComposeResponseV0(body)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.True(t, response.Status, "POST failed: %#v", response)
|
||||
buildID := response.BuildID
|
||||
|
||||
// Wait until the build is not listed in the queue
|
||||
resp, err = WaitForBuild(testState.socket, buildID)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
|
||||
// Test failed after compose (should not have failed)
|
||||
failed, resp, err := GetFailedComposesV0(testState.socket)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
require.False(t, UUIDInComposeResults(buildID, failed))
|
||||
|
||||
// Test finished after compose (should have finished)
|
||||
finished, resp, err := GetFinishedComposesV0(testState.socket)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
require.True(t, UUIDInComposeResults(buildID, finished), "%s not found in finished list: %#v", buildID, finished)
|
||||
|
||||
// Test status filter on finished compose
|
||||
status, resp, err := GetComposeStatusV0(testState.socket, "*", "", "FINISHED", "")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
require.True(t, UUIDInComposeResults(buildID, status), "%s not found in status list: %#v", buildID, status)
|
||||
|
||||
// Test status of build id
|
||||
status, resp, err = GetComposeStatusV0(testState.socket, buildID.String(), "", "", "")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
require.True(t, UUIDInComposeResults(buildID, status), "%s not found in status list: %#v", buildID, status)
|
||||
|
||||
// Test status filter using FAILED, should not be listed
|
||||
status, resp, err = GetComposeStatusV0(testState.socket, "*", "", "FAILED", "")
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.Nil(t, resp)
|
||||
require.False(t, UUIDInComposeResults(buildID, status))
|
||||
|
||||
}
|
||||
|
||||
func TestComposeUnsupportedMountPointV0(t *testing.T) {
|
||||
bp := `
|
||||
name="test-compose-unsupported-mountpoint-v0"
|
||||
description="TestComposeUnsupportedMountPointV0"
|
||||
version="0.0.1"
|
||||
[[customizations.filesystem]]
|
||||
mountpoint = "/boot"
|
||||
size = 4294967296
|
||||
`
|
||||
resp, err := PostTOMLBlueprintV0(testState.socket, bp)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-compose-unsupported-mountpoint-v0",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`, testState.imageTypeName)
|
||||
|
||||
// Create a finished test compose
|
||||
body, resp, err := PostJSON(testState.socket, "/api/v1/compose?test=2", compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
require.Equal(t, "ManifestCreationFailed", resp.Errors[0].ID)
|
||||
require.Contains(t, resp.Errors[0].Msg, "The following custom mountpoints are not supported")
|
||||
require.Equal(t, 0, len(body))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -401,7 +401,7 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) {
|
|||
if imgTypeName == "rhel-edge-commit" {
|
||||
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
|
||||
} else {
|
||||
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/var\"]")
|
||||
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package test_distro
|
|||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
|
|
@ -165,6 +166,19 @@ func (t *TestImageType) Exports() []string {
|
|||
}
|
||||
|
||||
func (t *TestImageType) Manifest(b *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, seed int64) (distro.Manifest, error) {
|
||||
mountpoints := b.GetFilesystems()
|
||||
|
||||
invalidMountpoints := []string{}
|
||||
for _, m := range mountpoints {
|
||||
if m.Mountpoint != "/" {
|
||||
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
|
||||
}
|
||||
}
|
||||
|
||||
if len(invalidMountpoints) > 0 {
|
||||
return nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
|
||||
}
|
||||
|
||||
return json.Marshal(
|
||||
osbuild.Manifest{
|
||||
Sources: osbuild.Sources{},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue