Tests: remove fedoratest and replace it with test_distro
fedoratest was yet another dummy distribution used by unit tests. After the rework of test_distro, there is no reason to not use it as the only distro implementation for testing purposes. Remove fedoratest distro and replace it with test_distro in all affected tests. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
e5dd45b71c
commit
f7f064274a
11 changed files with 151 additions and 270 deletions
|
|
@ -21,6 +21,7 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
|
@ -40,12 +41,12 @@ func TestComposeTypesV0(t *testing.T) {
|
|||
require.Greater(t, len(composeTypes), 0)
|
||||
var found bool
|
||||
for _, t := range composeTypes {
|
||||
if t.Name == "qcow2" && t.Enabled == true {
|
||||
if t.Name == testState.imageTypeName && t.Enabled == true {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
require.True(t, found, "qcow2 not in list of compose types: %#v", composeTypes)
|
||||
require.True(t, found, "%s not in list of compose types: %#v", testState.imageTypeName, composeTypes)
|
||||
}
|
||||
|
||||
// Test compose with invalid type fails
|
||||
|
|
@ -76,11 +77,11 @@ func TestComposeInvalidTypeV0(t *testing.T) {
|
|||
|
||||
// Test compose for unknown blueprint fails
|
||||
func TestComposeInvalidBlueprintV0(t *testing.T) {
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-invalid-bp-compose-v0",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
resp, err := PostComposeV0(testState.socket, compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
|
|
@ -91,11 +92,11 @@ func TestComposeInvalidBlueprintV0(t *testing.T) {
|
|||
|
||||
// Test compose for empty blueprint fails
|
||||
func TestComposeEmptyBlueprintV0(t *testing.T) {
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
resp, err := PostComposeV0(testState.socket, compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
|
|
@ -106,11 +107,11 @@ func TestComposeEmptyBlueprintV0(t *testing.T) {
|
|||
|
||||
// Test compose for blueprint with invalid characters fails
|
||||
func TestComposeInvalidCharsBlueprintV0(t *testing.T) {
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "I w𝒊ll 𝟉ο𝘁 𝛠a𝔰ꜱ 𝘁𝒉𝝸𝚜",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
resp, err := PostComposeV0(testState.socket, compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
require.NotNil(t, resp)
|
||||
|
|
@ -283,11 +284,11 @@ func TestFailedComposeV0(t *testing.T) {
|
|||
require.NoError(t, err, "failed with a client error")
|
||||
require.True(t, resp.Status, "POST failed: %#v", resp)
|
||||
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-failed-compose-v0",
|
||||
"compose_type": "qcow2",
|
||||
"compose_type": "%s",
|
||||
"branch": "master"
|
||||
}`
|
||||
}`, testState.imageTypeName)
|
||||
// Create a failed test compose
|
||||
body, resp, err := PostJSON(testState.socket, "/api/v1/compose?test=1", compose)
|
||||
require.NoError(t, err, "failed with a client error")
|
||||
|
|
@ -378,11 +379,11 @@ func TestFinishedComposeV0(t *testing.T) {
|
|||
require.NoError(t, err, "failed with a client error")
|
||||
require.True(t, resp.Status, "POST failed: %#v", resp)
|
||||
|
||||
compose := `{
|
||||
compose := fmt.Sprintf(`{
|
||||
"blueprint_name": "test-finished-compose-v0",
|
||||
"compose_type": "qcow2",
|
||||
"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")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ var testState *TestState
|
|||
// Also makes sure there is a running server to test against
|
||||
func executeTests(m *testing.M) int {
|
||||
var err error
|
||||
testState, err = setUpTestState("/run/weldr/api.socket", false)
|
||||
|
||||
testState, err = setUpTestState("/run/weldr/api.socket", "qcow2", false)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: Test setup failed: %s\n", err)
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/weldr"
|
||||
|
|
@ -44,8 +44,8 @@ func executeTests(m *testing.M) int {
|
|||
}
|
||||
fixture := rpmmd_mock.BaseFixture(path.Join(tmpdir, "/jobs"))
|
||||
rpm := rpmmd_mock.NewRPMMDMock(fixture)
|
||||
distro := fedoratest.New()
|
||||
arch, err := distro.GetArch("x86_64")
|
||||
distro := test_distro.New()
|
||||
arch, err := distro.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ func executeTests(m *testing.M) int {
|
|||
}
|
||||
}()
|
||||
|
||||
testState, err = setUpTestState(socketPath, true)
|
||||
testState, err = setUpTestState(socketPath, test_distro.TestImageTypeName, true)
|
||||
if err != nil {
|
||||
log.Fatalf("ERROR: Test setup failed: %s\n", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ import (
|
|||
)
|
||||
|
||||
type TestState struct {
|
||||
socket *http.Client
|
||||
apiVersion int
|
||||
repoDir string
|
||||
unitTest bool
|
||||
socket *http.Client
|
||||
apiVersion int
|
||||
repoDir string
|
||||
unitTest bool
|
||||
imageTypeName string
|
||||
}
|
||||
|
||||
// isStringInSlice returns true if the string is present, false if not
|
||||
|
|
@ -31,8 +32,8 @@ func isStringInSlice(slice []string, s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func setUpTestState(socketPath string, unitTest bool) (*TestState, error) {
|
||||
state := TestState{unitTest: unitTest}
|
||||
func setUpTestState(socketPath string, imageTypeName string, unitTest bool) (*TestState, error) {
|
||||
state := TestState{imageTypeName: imageTypeName, unitTest: unitTest}
|
||||
|
||||
state.socket = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
|||
|
|
@ -1,130 +0,0 @@
|
|||
package fedoratest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild1"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
const name = "fedora-30"
|
||||
const modulePlatformID = "platform:f30"
|
||||
|
||||
type FedoraTestDistro struct{}
|
||||
|
||||
type arch struct {
|
||||
name string
|
||||
distro *FedoraTestDistro
|
||||
}
|
||||
|
||||
type imageType struct {
|
||||
name string
|
||||
arch *arch
|
||||
}
|
||||
|
||||
func (a *arch) Distro() distro.Distro {
|
||||
return a.distro
|
||||
}
|
||||
|
||||
func (t *imageType) Arch() distro.Arch {
|
||||
return t.arch
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) ListArches() []string {
|
||||
return []string{"x86_64"}
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) GetArch(name string) (distro.Arch, error) {
|
||||
if name != "x86_64" {
|
||||
return nil, errors.New("invalid architecture: " + name)
|
||||
}
|
||||
|
||||
return &arch{
|
||||
name: name,
|
||||
distro: d,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *arch) Name() string {
|
||||
return a.name
|
||||
}
|
||||
|
||||
func (a *arch) ListImageTypes() []string {
|
||||
return []string{"qcow2"}
|
||||
}
|
||||
|
||||
func (a *arch) GetImageType(name string) (distro.ImageType, error) {
|
||||
if name != "qcow2" {
|
||||
return nil, errors.New("invalid image type: " + name)
|
||||
}
|
||||
|
||||
return &imageType{
|
||||
name: name,
|
||||
arch: a,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (t *imageType) Name() string {
|
||||
return t.name
|
||||
}
|
||||
|
||||
func (t *imageType) Filename() string {
|
||||
return "test.img"
|
||||
}
|
||||
|
||||
func (t *imageType) MIMEType() string {
|
||||
return "application/x-test"
|
||||
}
|
||||
|
||||
func (t *imageType) OSTreeRef() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
return size
|
||||
}
|
||||
|
||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (t *imageType) BuildPackages() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint) map[string]rpmmd.PackageSet {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *imageType) Exports() []string {
|
||||
return []string{"assembler"}
|
||||
}
|
||||
|
||||
func (t *imageType) Manifest(c *blueprint.Customizations,
|
||||
options distro.ImageOptions,
|
||||
repos []rpmmd.RepoConfig,
|
||||
packageSpecSets map[string][]rpmmd.PackageSpec,
|
||||
seed int64) (distro.Manifest, error) {
|
||||
|
||||
return json.Marshal(
|
||||
osbuild.Manifest{
|
||||
Sources: osbuild.Sources{},
|
||||
Pipeline: osbuild.Pipeline{},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func New() *FedoraTestDistro {
|
||||
return &FedoraTestDistro{}
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Name() string {
|
||||
return name
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) ModulePlatformID() string {
|
||||
return modulePlatformID
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/kojiapi"
|
||||
"github.com/osbuild/osbuild-composer/internal/kojiapi/api"
|
||||
distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro"
|
||||
|
|
@ -82,8 +83,8 @@ func TestCompose(t *testing.T) {
|
|||
Token: `"foobar"`,
|
||||
},
|
||||
buildResult: worker.OSBuildKojiJobResult{
|
||||
Arch: "x86_64",
|
||||
HostOS: "fedora-30",
|
||||
Arch: test_distro.TestArchName,
|
||||
HostOS: test_distro.TestDistroName,
|
||||
ImageHash: "browns",
|
||||
ImageSize: 42,
|
||||
OSBuildOutput: &osbuild.Result{
|
||||
|
|
@ -111,8 +112,8 @@ func TestCompose(t *testing.T) {
|
|||
KojiError: "failure",
|
||||
},
|
||||
buildResult: worker.OSBuildKojiJobResult{
|
||||
Arch: "x86_64",
|
||||
HostOS: "fedora-30",
|
||||
Arch: test_distro.TestArchName,
|
||||
HostOS: test_distro.TestDistroName,
|
||||
ImageHash: "browns",
|
||||
ImageSize: 42,
|
||||
OSBuildOutput: &osbuild.Result{
|
||||
|
|
@ -140,8 +141,8 @@ func TestCompose(t *testing.T) {
|
|||
Token: `"foobar"`,
|
||||
},
|
||||
buildResult: worker.OSBuildKojiJobResult{
|
||||
Arch: "x86_64",
|
||||
HostOS: "fedora-30",
|
||||
Arch: test_distro.TestArchName,
|
||||
HostOS: test_distro.TestDistroName,
|
||||
ImageHash: "browns",
|
||||
ImageSize: 42,
|
||||
OSBuildOutput: &osbuild.Result{
|
||||
|
|
@ -170,8 +171,8 @@ func TestCompose(t *testing.T) {
|
|||
Token: `"foobar"`,
|
||||
},
|
||||
buildResult: worker.OSBuildKojiJobResult{
|
||||
Arch: "x86_64",
|
||||
HostOS: "fedora-30",
|
||||
Arch: test_distro.TestArchName,
|
||||
HostOS: test_distro.TestDistroName,
|
||||
ImageHash: "browns",
|
||||
ImageSize: 42,
|
||||
OSBuildOutput: &osbuild.Result{
|
||||
|
|
@ -201,8 +202,8 @@ func TestCompose(t *testing.T) {
|
|||
Token: `"foobar"`,
|
||||
},
|
||||
buildResult: worker.OSBuildKojiJobResult{
|
||||
Arch: "x86_64",
|
||||
HostOS: "fedora-30",
|
||||
Arch: test_distro.TestArchName,
|
||||
HostOS: test_distro.TestDistroName,
|
||||
ImageHash: "browns",
|
||||
ImageSize: 42,
|
||||
OSBuildOutput: &osbuild.Result{
|
||||
|
|
@ -234,7 +235,7 @@ func TestCompose(t *testing.T) {
|
|||
wg.Add(1)
|
||||
|
||||
go func(t *testing.T, result worker.KojiInitJobResult) {
|
||||
token, _, jobType, rawJob, _, err := workerServer.RequestJob(context.Background(), "x86_64", []string{"koji-init"})
|
||||
token, _, jobType, rawJob, _, err := workerServer.RequestJob(context.Background(), test_distro.TestArchName, []string{"koji-init"})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "koji-init", jobType)
|
||||
|
||||
|
|
@ -253,16 +254,16 @@ func TestCompose(t *testing.T) {
|
|||
wg.Done()
|
||||
}(t, c.initResult)
|
||||
|
||||
test.TestRoute(t, handler, false, "POST", "/api/composer-koji/v1/compose", `
|
||||
test.TestRoute(t, handler, false, "POST", "/api/composer-koji/v1/compose", fmt.Sprintf(`
|
||||
{
|
||||
"name":"foo",
|
||||
"version":"1",
|
||||
"release":"2",
|
||||
"distribution":"fedora-30",
|
||||
"distribution":"%[1]s",
|
||||
"image_requests": [
|
||||
{
|
||||
"architecture": "x86_64",
|
||||
"image_type": "qcow2",
|
||||
"architecture": "%[2]s",
|
||||
"image_type": "%[3]s",
|
||||
"repositories": [
|
||||
{
|
||||
"baseurl": "https://repo.example.com/"
|
||||
|
|
@ -270,8 +271,8 @@ func TestCompose(t *testing.T) {
|
|||
]
|
||||
},
|
||||
{
|
||||
"architecture": "x86_64",
|
||||
"image_type": "qcow2",
|
||||
"architecture": "%[2]s",
|
||||
"image_type": "%[3]s",
|
||||
"repositories": [
|
||||
{
|
||||
"baseurl": "https://repo.example.com/"
|
||||
|
|
@ -282,10 +283,11 @@ func TestCompose(t *testing.T) {
|
|||
"koji": {
|
||||
"server": "koji.example.com"
|
||||
}
|
||||
}`, c.composeReplyCode, c.composeReply, "id")
|
||||
}`, test_distro.TestDistroName, test_distro.TestArchName, test_distro.TestImageTypeName),
|
||||
c.composeReplyCode, c.composeReply, "id")
|
||||
wg.Wait()
|
||||
|
||||
token, _, jobType, rawJob, _, err := workerServer.RequestJob(context.Background(), "x86_64", []string{"osbuild-koji"})
|
||||
token, _, jobType, rawJob, _, err := workerServer.RequestJob(context.Background(), test_distro.TestArchName, []string{"osbuild-koji"})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "osbuild-koji", jobType)
|
||||
|
||||
|
|
@ -300,7 +302,7 @@ func TestCompose(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
test.TestRoute(t, workerHandler, false, "PATCH", fmt.Sprintf("/api/worker/v1/jobs/%v", token), string(buildJobResult), http.StatusOK, `{}`)
|
||||
|
||||
token, _, jobType, rawJob, _, err = workerServer.RequestJob(context.Background(), "x86_64", []string{"osbuild-koji"})
|
||||
token, _, jobType, rawJob, _, err = workerServer.RequestJob(context.Background(), test_distro.TestArchName, []string{"osbuild-koji"})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "osbuild-koji", jobType)
|
||||
|
||||
|
|
@ -310,19 +312,19 @@ func TestCompose(t *testing.T) {
|
|||
require.Equal(t, "test.img", osbuildJob.ImageName)
|
||||
require.NotEmpty(t, osbuildJob.KojiDirectory)
|
||||
|
||||
test.TestRoute(t, workerHandler, false, "PATCH", fmt.Sprintf("/api/worker/v1/jobs/%v", token), `{
|
||||
test.TestRoute(t, workerHandler, false, "PATCH", fmt.Sprintf("/api/worker/v1/jobs/%v", token), fmt.Sprintf(`{
|
||||
"result": {
|
||||
"arch": "x86_64",
|
||||
"host_os": "fedora-30",
|
||||
"arch": "%s",
|
||||
"host_os": "%s",
|
||||
"image_hash": "browns",
|
||||
"image_size": 42,
|
||||
"osbuild_output": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
}`, http.StatusOK, `{}`)
|
||||
}`, test_distro.TestArchName, test_distro.TestDistroName), http.StatusOK, `{}`)
|
||||
|
||||
token, finalizeID, jobType, rawJob, _, err := workerServer.RequestJob(context.Background(), "x86_64", []string{"koji-finalize"})
|
||||
token, finalizeID, jobType, rawJob, _, err := workerServer.RequestJob(context.Background(), test_distro.TestArchName, []string{"koji-finalize"})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "koji-finalize", jobType)
|
||||
|
||||
|
|
@ -332,7 +334,10 @@ func TestCompose(t *testing.T) {
|
|||
require.Equal(t, "koji.example.com", kojiFinalizeJob.Server)
|
||||
require.Equal(t, "1", kojiFinalizeJob.Version)
|
||||
require.Equal(t, "2", kojiFinalizeJob.Release)
|
||||
require.ElementsMatch(t, []string{"foo-1-2.x86_64.img", "foo-1-2.x86_64.img"}, kojiFinalizeJob.KojiFilenames)
|
||||
require.ElementsMatch(t, []string{
|
||||
fmt.Sprintf("foo-1-2.%s.img", test_distro.TestArchName),
|
||||
fmt.Sprintf("foo-1-2.%s.img", test_distro.TestArchName),
|
||||
}, kojiFinalizeJob.KojiFilenames)
|
||||
require.NotEmpty(t, kojiFinalizeJob.KojiDirectory)
|
||||
|
||||
finalizeResult, err := json.Marshal(&jobResult{Result: c.finalizeResult})
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
package distro_mock
|
||||
|
||||
import (
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||
)
|
||||
|
||||
func NewDefaultRegistry() (*distroregistry.Registry, error) {
|
||||
ftest := fedoratest.New()
|
||||
if ftest == nil {
|
||||
panic("Attempt to register Fedora test failed")
|
||||
testDistro := test_distro.New()
|
||||
if testDistro == nil {
|
||||
panic("Attempt to register test distro failed")
|
||||
}
|
||||
return distroregistry.New(ftest)
|
||||
return distroregistry.New(testDistro)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
)
|
||||
|
|
@ -49,18 +50,18 @@ func FixtureBase() *Store {
|
|||
},
|
||||
}
|
||||
|
||||
d := fedoratest.New()
|
||||
arch, err := d.GetArch("x86_64")
|
||||
d := test_distro.New()
|
||||
arch, err := d.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic("invalid architecture x86_64 for fedoratest")
|
||||
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
|
||||
}
|
||||
imgType, err := arch.GetImageType("qcow2")
|
||||
imgType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
if err != nil {
|
||||
panic("invalid image type qcow2 for x86_64 @ fedoratest")
|
||||
panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err))
|
||||
}
|
||||
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0)
|
||||
if err != nil {
|
||||
panic("could not create manifest")
|
||||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
s := New(nil, arch, nil)
|
||||
|
||||
|
|
@ -70,13 +71,13 @@ func FixtureBase() *Store {
|
|||
Epoch: 0,
|
||||
Version: "2.11.2",
|
||||
Release: "1.fc35",
|
||||
Arch: "x86_64",
|
||||
Arch: test_distro.TestArchName,
|
||||
}, {
|
||||
Name: "test2",
|
||||
Epoch: 3,
|
||||
Version: "4.2.2",
|
||||
Release: "1.fc35",
|
||||
Arch: "x86_64",
|
||||
Arch: test_distro.TestArchName,
|
||||
}}
|
||||
|
||||
s.blueprints[bName] = b
|
||||
|
|
@ -184,18 +185,18 @@ func FixtureFinished() *Store {
|
|||
},
|
||||
}
|
||||
|
||||
d := fedoratest.New()
|
||||
arch, err := d.GetArch("x86_64")
|
||||
d := test_distro.New()
|
||||
arch, err := d.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic("invalid architecture x86_64 for fedoratest")
|
||||
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
|
||||
}
|
||||
imgType, err := arch.GetImageType("qcow2")
|
||||
imgType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
if err != nil {
|
||||
panic("invalid image type qcow2 for x86_64 @ fedoratest")
|
||||
panic(fmt.Sprintf("failed to get image type %s for a test distro architecture: %v", test_distro.TestImageTypeName, err))
|
||||
}
|
||||
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0)
|
||||
if err != nil {
|
||||
panic("could not create manifest")
|
||||
panic(fmt.Sprintf("failed to create a manifest: %v", err))
|
||||
}
|
||||
s := New(nil, arch, nil)
|
||||
|
||||
|
|
@ -205,13 +206,13 @@ func FixtureFinished() *Store {
|
|||
Epoch: 0,
|
||||
Version: "2.11.2",
|
||||
Release: "1.fc35",
|
||||
Arch: "x86_64",
|
||||
Arch: test_distro.TestArchName,
|
||||
}, {
|
||||
Name: "test2",
|
||||
Epoch: 3,
|
||||
Version: "4.2.2",
|
||||
Release: "1.fc35",
|
||||
Arch: "x86_64",
|
||||
Arch: test_distro.TestArchName,
|
||||
}}
|
||||
|
||||
s.blueprints[bName] = b
|
||||
|
|
@ -280,11 +281,12 @@ func FixtureEmpty() *Store {
|
|||
Customizations: nil,
|
||||
}
|
||||
|
||||
d := fedoratest.New()
|
||||
arch, err := d.GetArch("x86_64")
|
||||
d := test_distro.New()
|
||||
arch, err := d.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic("invalid architecture x86_64 for fedoratest")
|
||||
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
|
||||
}
|
||||
|
||||
s := New(nil, arch, nil)
|
||||
|
||||
s.blueprints[bName] = b
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package store
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
|
@ -13,7 +14,6 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
|
|
@ -113,10 +113,10 @@ func Test_imageTypeFromCompatString(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMarshalEmpty(t *testing.T) {
|
||||
d := fedoratest.New()
|
||||
arch, err := d.GetArch("x86_64")
|
||||
d := test_distro.New()
|
||||
arch, err := d.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic("invalid architecture x86_64 for fedoratest")
|
||||
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
|
||||
}
|
||||
store1 := FixtureEmpty()
|
||||
storeV0 := store1.toStoreV0()
|
||||
|
|
@ -127,10 +127,10 @@ func TestMarshalEmpty(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMarshalFinished(t *testing.T) {
|
||||
d := fedoratest.New()
|
||||
arch, err := d.GetArch("x86_64")
|
||||
d := test_distro.New()
|
||||
arch, err := d.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic("invalid architecture x86_64 for fedoratest")
|
||||
panic(fmt.Sprintf("failed to get architecture %s for a test distro: %v", test_distro.TestArchName, err))
|
||||
}
|
||||
store1 := FixtureFinished()
|
||||
storeV0 := store1.toStoreV0()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
test_distro "github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/store"
|
||||
|
|
@ -36,7 +36,7 @@ func createWeldrAPI(tempdir string, fixtureGenerator rpmmd_mock.FixtureGenerator
|
|||
rpm := rpmmd_mock.NewRPMMDMock(fixture)
|
||||
repos := []rpmmd.RepoConfig{{Name: "test-id", BaseURL: "http://example.com/test/os/x86_64", CheckGPG: true}}
|
||||
d := test_distro.New()
|
||||
arch, err := d.GetArch("x86_64")
|
||||
arch, err := d.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -576,9 +576,9 @@ func TestBlueprintsUndo(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCompose(t *testing.T) {
|
||||
arch, err := test_distro.New().GetArch("x86_64")
|
||||
arch, err := test_distro.New().GetArch(test_distro.TestArchName)
|
||||
require.NoError(t, err)
|
||||
imgType, err := arch.GetImageType("qcow2")
|
||||
imgType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
require.NoError(t, err)
|
||||
manifest, err := imgType.Manifest(nil, distro.ImageOptions{}, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -673,13 +673,13 @@ func TestCompose(t *testing.T) {
|
|||
ExpectedCompose *store.Compose
|
||||
IgnoreFields []string
|
||||
}{
|
||||
{true, "POST", "/api/v0/compose", `{"blueprint_name": "http-server","compose_type": "qcow2","branch": "master"}`, http.StatusBadRequest, `{"status":false,"errors":[{"id":"UnknownBlueprint","msg":"Unknown blueprint name: http-server"}]}`, nil, []string{"build_id"}},
|
||||
{false, "POST", "/api/v0/compose", `{"blueprint_name": "test","compose_type": "qcow2","branch": "master"}`, http.StatusOK, `{"status": true}`, expectedComposeLocal, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", `{"blueprint_name": "test","compose_type":"qcow2","branch":"master","upload":{"image_name":"test_upload","provider":"aws","settings":{"region":"frankfurt","accessKeyID":"accesskey","secretAccessKey":"secretkey","bucket":"clay","key":"imagekey"}}}`, http.StatusOK, `{"status": true}`, expectedComposeLocalAndAws, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", `{"blueprint_name": "test","compose_type":"qcow2","branch":"master","ostree":{"ref":"refid","parent":"parentid","url":""}}`, http.StatusOK, `{"status": true}`, expectedComposeOSTreeRef, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose?test=2", `{"blueprint_name": "test","compose_type":"qcow2","branch":"master","ostree":{"ref":"refid","parent":"","url":"http://ostree/"}}`, http.StatusOK, `{"status": true}`, expectedComposeOSTreeURL, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", `{"blueprint_name": "test","compose_type":"qcow2","branch":"master","ostree":{"ref":"refid","parent":"","url":"invalid-url"}}`, http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeCommitError","msg":"Get \"invalid-url/refs/heads/refid\": unsupported protocol scheme \"\""}]}`, nil, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", `{"blueprint_name": "test","compose_type":"qcow2","branch":"master","ostree":{"ref":"/bad/ref","parent":"","url":"http://ostree/"}}`, http.StatusBadRequest, `{"status":false,"errors":[{"id":"InvalidChars","msg":"Invalid ostree ref"}]}`, expectedComposeOSTreeURL, []string{"build_id"}},
|
||||
{true, "POST", "/api/v0/compose", fmt.Sprintf(`{"blueprint_name": "http-server","compose_type": "%s","branch": "master"}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"UnknownBlueprint","msg":"Unknown blueprint name: http-server"}]}`, nil, []string{"build_id"}},
|
||||
{false, "POST", "/api/v0/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type": "%s","branch": "master"}`, test_distro.TestImageTypeName), http.StatusOK, `{"status": true}`, expectedComposeLocal, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","upload":{"image_name":"test_upload","provider":"aws","settings":{"region":"frankfurt","accessKeyID":"accesskey","secretAccessKey":"secretkey","bucket":"clay","key":"imagekey"}}}`, test_distro.TestImageTypeName), http.StatusOK, `{"status": true}`, expectedComposeLocalAndAws, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"parentid","url":""}}`, test_distro.TestImageTypeName), http.StatusOK, `{"status": true}`, expectedComposeOSTreeRef, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose?test=2", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusOK, `{"status": true}`, expectedComposeOSTreeURL, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"refid","parent":"","url":"invalid-url"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"OSTreeCommitError","msg":"Get \"invalid-url/refs/heads/refid\": unsupported protocol scheme \"\""}]}`, nil, []string{"build_id"}},
|
||||
{false, "POST", "/api/v1/compose", fmt.Sprintf(`{"blueprint_name": "test","compose_type":"%s","branch":"master","ostree":{"ref":"/bad/ref","parent":"","url":"http://ostree/"}}`, test_distro.TestImageTypeName), http.StatusBadRequest, `{"status":false,"errors":[{"id":"InvalidChars","msg":"Invalid ostree ref"}]}`, expectedComposeOSTreeURL, []string{"build_id"}},
|
||||
}
|
||||
|
||||
tempdir, err := ioutil.TempDir("", "weldr-tests-")
|
||||
|
|
@ -757,12 +757,12 @@ func TestComposeStatus(t *testing.T) {
|
|||
ExpectedStatus int
|
||||
ExpectedJSON string
|
||||
}{
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/30000000-0000-0000-0000-000000000000,30000000-0000-0000-0000-000000000002", ``, http.StatusOK, `{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/*", ``, http.StatusOK, `{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000001","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"RUNNING","job_created":1574857140,"job_started":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/*?name=test", ``, http.StatusOK, `{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000001","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"RUNNING","job_created":1574857140,"job_started":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/*?status=FINISHED", ``, http.StatusOK, `{"uuids":[{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/*?type=qcow2", ``, http.StatusOK, `{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000001","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"RUNNING","job_created":1574857140,"job_started":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/status/30000000-0000-0000-0000-000000000000", ``, http.StatusOK, `{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"WAITING","job_created":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"WAITING","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/30000000-0000-0000-0000-000000000000,30000000-0000-0000-0000-000000000002", ``, http.StatusOK, fmt.Sprintf(`{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/*", ``, http.StatusOK, fmt.Sprintf(`{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000001","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"RUNNING","job_created":1574857140,"job_started":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/*?name=test", ``, http.StatusOK, fmt.Sprintf(`{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000001","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"RUNNING","job_created":1574857140,"job_started":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/status/*?status=FINISHED", ``, http.StatusOK, fmt.Sprintf(`{"uuids":[{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", fmt.Sprintf("/api/v0/compose/status/*?type=%s", test_distro.TestImageTypeName), ``, http.StatusOK, fmt.Sprintf(`{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"WAITING","job_created":1574857140},{"id":"30000000-0000-0000-0000-000000000001","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"RUNNING","job_created":1574857140,"job_started":1574857140},{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/status/30000000-0000-0000-0000-000000000000", ``, http.StatusOK, fmt.Sprintf(`{"uuids":[{"id":"30000000-0000-0000-0000-000000000000","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"WAITING","job_created":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"WAITING","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}]}`, test_distro.TestImageTypeName)},
|
||||
}
|
||||
|
||||
if len(os.Getenv("OSBUILD_COMPOSER_TEST_EXTERNAL")) > 0 {
|
||||
|
|
@ -788,8 +788,8 @@ func TestComposeInfo(t *testing.T) {
|
|||
ExpectedStatus int
|
||||
ExpectedJSON string
|
||||
}{
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/info/30000000-0000-0000-0000-000000000000", ``, http.StatusOK, `{"id":"30000000-0000-0000-0000-000000000000","config":"","blueprint":{"name":"test","description":"","version":"0.0.0","packages":[],"modules":[],"groups":[]},"commit":"","deps":{"packages":[]},"compose_type":"qcow2","queue_status":"WAITING","image_size":0}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/info/30000000-0000-0000-0000-000000000000", ``, http.StatusOK, `{"id":"30000000-0000-0000-0000-000000000000","config":"","blueprint":{"name":"test","description":"","version":"0.0.0","packages":[],"modules":[],"groups":[]},"commit":"","deps":{"packages":[]},"compose_type":"qcow2","queue_status":"WAITING","image_size":0,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"WAITING","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/info/30000000-0000-0000-0000-000000000000", ``, http.StatusOK, fmt.Sprintf(`{"id":"30000000-0000-0000-0000-000000000000","config":"","blueprint":{"name":"test","description":"","version":"0.0.0","packages":[],"modules":[],"groups":[]},"commit":"","deps":{"packages":[]},"compose_type":"%s","queue_status":"WAITING","image_size":0}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/info/30000000-0000-0000-0000-000000000000", ``, http.StatusOK, fmt.Sprintf(`{"id":"30000000-0000-0000-0000-000000000000","config":"","blueprint":{"name":"test","description":"","version":"0.0.0","packages":[],"modules":[],"groups":[]},"commit":"","deps":{"packages":[]},"compose_type":"%s","queue_status":"WAITING","image_size":0,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"WAITING","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/info/30000000-0000-0000-0000", ``, http.StatusBadRequest, `{"status":false,"errors":[{"id":"UnknownUUID","msg":"30000000-0000-0000-0000 is not a valid build uuid"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/info/42000000-0000-0000-0000-000000000000", ``, http.StatusBadRequest, `{"status":false,"errors":[{"id":"UnknownUUID","msg":"42000000-0000-0000-0000-000000000000 is not a valid build uuid"}]}`},
|
||||
}
|
||||
|
|
@ -916,8 +916,8 @@ func TestComposeQueue(t *testing.T) {
|
|||
ExpectedStatus int
|
||||
ExpectedJSON string
|
||||
}{
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/queue", ``, http.StatusOK, `{"new":[{"blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"WAITING"}],"run":[{"blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"RUNNING"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/queue", ``, http.StatusOK, `{"new":[{"blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"WAITING","uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"WAITING","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}],"run":[{"blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"RUNNING"}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/queue", ``, http.StatusOK, fmt.Sprintf(`{"new":[{"blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"WAITING"}],"run":[{"blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"RUNNING"}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/queue", ``, http.StatusOK, fmt.Sprintf(`{"new":[{"blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"WAITING","uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"WAITING","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}],"run":[{"blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"RUNNING"}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.NoComposesFixture, "GET", "/api/v0/compose/queue", ``, http.StatusOK, `{"new":[],"run":[]}`},
|
||||
}
|
||||
|
||||
|
|
@ -944,8 +944,8 @@ func TestComposeFinished(t *testing.T) {
|
|||
ExpectedStatus int
|
||||
ExpectedJSON string
|
||||
}{
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/finished", ``, http.StatusOK, `{"finished":[{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/finished", ``, http.StatusOK, `{"finished":[{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"FINISHED","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"FINISHED","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/finished", ``, http.StatusOK, fmt.Sprintf(`{"finished":[{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/finished", ``, http.StatusOK, fmt.Sprintf(`{"finished":[{"id":"30000000-0000-0000-0000-000000000002","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"FINISHED","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]},{"id":"30000000-0000-0000-0000-000000000004","blueprint":"test","version":"0.0.0","compose_type":"%[1]s","image_size":0,"queue_status":"FINISHED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"FINISHED","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.NoComposesFixture, "GET", "/api/v0/compose/finished", ``, http.StatusOK, `{"finished":[]}`},
|
||||
}
|
||||
|
||||
|
|
@ -972,8 +972,8 @@ func TestComposeFailed(t *testing.T) {
|
|||
ExpectedStatus int
|
||||
ExpectedJSON string
|
||||
}{
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/failed", ``, http.StatusOK, `{"failed":[{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/failed", ``, http.StatusOK, `{"failed":[{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"qcow2","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"FAILED","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}]}`},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v0/compose/failed", ``, http.StatusOK, fmt.Sprintf(`{"failed":[{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"%s","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.BaseFixture, "GET", "/api/v1/compose/failed", ``, http.StatusOK, fmt.Sprintf(`{"failed":[{"id":"30000000-0000-0000-0000-000000000003","blueprint":"test","version":"0.0.0","compose_type":"%s","image_size":0,"queue_status":"FAILED","job_created":1574857140,"job_started":1574857140,"job_finished":1574857140,"uploads":[{"uuid":"10000000-0000-0000-0000-000000000000","status":"FAILED","provider_name":"aws","image_name":"awsimage","creation_time":1574857140,"settings":{"region":"frankfurt","bucket":"clay","key":"imagekey"}}]}]}`, test_distro.TestImageTypeName)},
|
||||
{rpmmd_mock.NoComposesFixture, "GET", "/api/v0/compose/failed", ``, http.StatusOK, `{"failed":[]}`},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedoratest"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/test_distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue"
|
||||
"github.com/osbuild/osbuild-composer/internal/test"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
|
|
@ -74,18 +74,18 @@ func TestCreate(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempdir)
|
||||
|
||||
distroStruct := fedoratest.New()
|
||||
arch, err := distroStruct.GetArch("x86_64")
|
||||
distroStruct := test_distro.New()
|
||||
arch, err := distroStruct.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting arch from distro")
|
||||
t.Fatalf("error getting arch from distro: %v", err)
|
||||
}
|
||||
imageType, err := arch.GetImageType("qcow2")
|
||||
imageType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting image type from arch")
|
||||
t.Fatalf("error getting image type from arch: %v", err)
|
||||
}
|
||||
manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest")
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, tempdir)
|
||||
handler := server.Handler()
|
||||
|
|
@ -93,7 +93,8 @@ func TestCreate(t *testing.T) {
|
|||
_, err = server.EnqueueOSBuild(arch.Name(), &worker.OSBuildJob{Manifest: manifest})
|
||||
require.NoError(t, err)
|
||||
|
||||
test.TestRoute(t, handler, false, "POST", "/api/worker/v1/jobs", `{"types":["osbuild"],"arch":"x86_64"}`, http.StatusCreated,
|
||||
test.TestRoute(t, handler, false, "POST", "/api/worker/v1/jobs",
|
||||
fmt.Sprintf(`{"types":["osbuild"],"arch":"%s"}`, test_distro.TestArchName), http.StatusCreated,
|
||||
`{"type":"osbuild","args":{"manifest":{"pipeline":{},"sources":{}}}}`, "id", "location", "artifact_location")
|
||||
}
|
||||
|
||||
|
|
@ -102,18 +103,18 @@ func TestCancel(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempdir)
|
||||
|
||||
distroStruct := fedoratest.New()
|
||||
arch, err := distroStruct.GetArch("x86_64")
|
||||
distroStruct := test_distro.New()
|
||||
arch, err := distroStruct.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting arch from distro")
|
||||
t.Fatalf("error getting arch from distro: %v", err)
|
||||
}
|
||||
imageType, err := arch.GetImageType("qcow2")
|
||||
imageType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting image type from arch")
|
||||
t.Fatalf("error getting image type from arch: %v", err)
|
||||
}
|
||||
manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest")
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, tempdir)
|
||||
handler := server.Handler()
|
||||
|
|
@ -143,18 +144,18 @@ func TestUpdate(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempdir)
|
||||
|
||||
distroStruct := fedoratest.New()
|
||||
arch, err := distroStruct.GetArch("x86_64")
|
||||
distroStruct := test_distro.New()
|
||||
arch, err := distroStruct.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting arch from distro")
|
||||
t.Fatalf("error getting arch from distro: %v", err)
|
||||
}
|
||||
imageType, err := arch.GetImageType("qcow2")
|
||||
imageType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting image type from arch")
|
||||
t.Fatalf("error getting image type from arch: %v", err)
|
||||
}
|
||||
manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest")
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, tempdir)
|
||||
handler := server.Handler()
|
||||
|
|
@ -174,10 +175,10 @@ func TestUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestArgs(t *testing.T) {
|
||||
distroStruct := fedoratest.New()
|
||||
arch, err := distroStruct.GetArch("x86_64")
|
||||
distroStruct := test_distro.New()
|
||||
arch, err := distroStruct.GetArch(test_distro.TestArchName)
|
||||
require.NoError(t, err)
|
||||
imageType, err := arch.GetImageType("qcow2")
|
||||
imageType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
require.NoError(t, err)
|
||||
manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0)
|
||||
require.NoError(t, err)
|
||||
|
|
@ -212,18 +213,18 @@ func TestUpload(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer os.RemoveAll(tempdir)
|
||||
|
||||
distroStruct := fedoratest.New()
|
||||
arch, err := distroStruct.GetArch("x86_64")
|
||||
distroStruct := test_distro.New()
|
||||
arch, err := distroStruct.GetArch(test_distro.TestArchName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting arch from distro")
|
||||
t.Fatalf("error getting arch from distro: %v", err)
|
||||
}
|
||||
imageType, err := arch.GetImageType("qcow2")
|
||||
imageType, err := arch.GetImageType(test_distro.TestImageTypeName)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting image type from arch")
|
||||
t.Fatalf("error getting image type from arch: %v", err)
|
||||
}
|
||||
manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, nil, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating osbuild manifest")
|
||||
t.Fatalf("error creating osbuild manifest: %v", err)
|
||||
}
|
||||
server := newTestServer(t, tempdir)
|
||||
handler := server.Handler()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue