Repository: osbuild/osbuild-composer
Pull request #156 (2019-12-10 02:58:35)

Random fixes for lorax' integration tests
This includes the commits from https://github.com/osbuild/osbuild-composer/pull/150. Please merge that first.


Patch:
diff --git a/cmd/osbuild-pipeline/main.go b/cmd/osbuild-pipeline/main.go
index c7183968c..20b2013a3 100644
--- a/cmd/osbuild-pipeline/main.go
+++ b/cmd/osbuild-pipeline/main.go
@@ -24,11 +24,11 @@ func main() {
 	if blueprintArg != "" {
 		file, err := ioutil.ReadFile(blueprintArg)
 		if err != nil {
-			panic("Colud not find blueprint")
+			panic("Could not find blueprint: " + err.Error())
 		}
 		err = json.Unmarshal([]byte(file), &blueprint)
 		if err != nil {
-			panic("Colud not parse blueprint")
+			panic("Could not parse blueprint: " + err.Error())
 		}
 	}
 
diff --git a/internal/blueprint/blueprint.go b/internal/blueprint/blueprint.go
index 2b3b39054..a8e345182 100644
--- a/internal/blueprint/blueprint.go
+++ b/internal/blueprint/blueprint.go
@@ -3,15 +3,12 @@ package blueprint
 
 // A Blueprint is a high-level description of an image.
 type Blueprint struct {
-	Name        string    `json:"name" toml:"name"`
-	Description string    `json:"description" toml:"description"`
-	Version     string    `json:"version,omitempty" toml:"version,omitempty"`
-	Packages    []Package `json:"packages" toml:"packages"`
-
-	// skip "omitempty" for json, because cockpit-composer chokes when the keys are missing
-	Modules []Package `json:"modules" toml:"modules,omitempty"`
-	Groups  []Group   `json:"groups" toml:"groups,omitempty"`
-
+	Name           string          `json:"name" toml:"name"`
+	Description    string          `json:"description" toml:"description"`
+	Version        string          `json:"version,omitempty" toml:"version,omitempty"`
+	Packages       []Package       `json:"packages" toml:"packages"`
+	Modules        []Package       `json:"modules" toml:"modules"`
+	Groups         []Group         `json:"groups" toml:"groups"`
 	Customizations *Customizations `json:"customizations,omitempty" toml:"customizations,omitempty"`
 }
 
diff --git a/internal/distro/fedora30/distro.go b/internal/distro/fedora30/distro.go
index c21389d57..59b3edea4 100644
--- a/internal/distro/fedora30/distro.go
+++ b/internal/distro/fedora30/distro.go
@@ -101,7 +101,7 @@ func New() *Fedora30 {
 	}
 
 	r.outputs["qcow2"] = output{
-		Name:     "image.qcow2",
+		Name:     "disk.qcow2",
 		MimeType: "application/x-qemu-disk",
 		Packages: []string{
 			"kernel-core",
@@ -122,7 +122,7 @@ func New() *Fedora30 {
 		},
 		KernelOptions: "ro biosdevname=0 net.ifnames=0",
 		IncludeFSTab:  true,
-		Assembler:     r.qemuAssembler("qcow2", "image.qcow2"),
+		Assembler:     r.qemuAssembler("qcow2", "disk.qcow2"),
 	}
 
 	r.outputs["openstack"] = output{
diff --git a/internal/distro/rhel82/distro.go b/internal/distro/rhel82/distro.go
index 44dbc6dcf..73497d140 100644
--- a/internal/distro/rhel82/distro.go
+++ b/internal/distro/rhel82/distro.go
@@ -150,7 +150,7 @@ func New() *RHEL82 {
 	}
 
 	r.outputs["qcow2"] = output{
-		Name:     "image.qcow2",
+		Name:     "disk.qcow2",
 		MimeType: "application/x-qemu-disk",
 		Packages: []string{
 			"kernel-core",
@@ -170,7 +170,7 @@ func New() *RHEL82 {
 		},
 		IncludeFSTab:  true,
 		KernelOptions: "ro net.ifnames=0",
-		Assembler:     r.qemuAssembler("qcow2", "image.qcow2", 3*GigaByte),
+		Assembler:     r.qemuAssembler("qcow2", "disk.qcow2", 3*GigaByte),
 	}
 
 	r.outputs["openstack"] = output{
diff --git a/internal/weldr/api.go b/internal/weldr/api.go
index 7a63df8de..79d341279 100644
--- a/internal/weldr/api.go
+++ b/internal/weldr/api.go
@@ -1415,12 +1415,16 @@ func (api *API) composeInfoHandler(writer http.ResponseWriter, request *http.Req
 		return
 	}
 
+	type Dependencies struct {
+		Packages []map[string]interface{} `json:"packages"`
+	}
+
 	var reply struct {
 		ID          uuid.UUID            `json:"id"`
 		Config      string               `json:"config"`    // anaconda config, let's ignore this field
 		Blueprint   *blueprint.Blueprint `json:"blueprint"` // blueprint not frozen!
 		Commit      string               `json:"commit"`    // empty for now
-		Deps        []string             `json:"deps"`      // empty for now
+		Deps        Dependencies         `json:"deps"`      // empty for now
 		ComposeType string               `json:"compose_type"`
 		QueueStatus string               `json:"queue_status"`
 		ImageSize   int64                `json:"image_size"`
@@ -1429,7 +1433,9 @@ func (api *API) composeInfoHandler(writer http.ResponseWriter, request *http.Req
 
 	reply.ID = id
 	reply.Blueprint = compose.Blueprint
-	reply.Deps = []string{}
+	reply.Deps = Dependencies{
+		Packages: make([]map[string]interface{}, 0),
+	}
 	reply.ComposeType = compose.OutputType
 	reply.QueueStatus = compose.QueueStatus
 	if compose.Image != nil {


Test patch:
diff --git a/internal/distro/fedora30/distro_test.go b/internal/distro/fedora30/distro_test.go
index d4af43106..f6c7a4f30 100644
--- a/internal/distro/fedora30/distro_test.go
+++ b/internal/distro/fedora30/distro_test.go
@@ -63,7 +63,7 @@ func TestFilenameFromType(t *testing.T) {
 		{
 			name:  "qcow2",
 			args:  args{"qcow2"},
-			want:  "image.qcow2",
+			want:  "disk.qcow2",
 			want1: "application/x-qemu-disk",
 		},
 		{
diff --git a/internal/distro/rhel82/distro_test.go b/internal/distro/rhel82/distro_test.go
index 1deccdd79..3a7bf6044 100644
--- a/internal/distro/rhel82/distro_test.go
+++ b/internal/distro/rhel82/distro_test.go
@@ -63,7 +63,7 @@ func TestFilenameFromType(t *testing.T) {
 		{
 			name:  "qcow2",
 			args:  args{"qcow2"},
-			want:  "image.qcow2",
+			want:  "disk.qcow2",
 			want1: "application/x-qemu-disk",
 		},
 		{
diff --git a/internal/weldr/api_test.go b/internal/weldr/api_test.go
index 2f51e5cce..d7dec5b65 100644
--- a/internal/weldr/api_test.go
+++ b/internal/weldr/api_test.go
@@ -170,6 +170,8 @@ func TestBlueprintsInfoToml(t *testing.T) {
 		Packages: []blueprint.Package{
 			{"httpd", "2.4.*"},
 		},
+		Groups:  []blueprint.Group{},
+		Modules: []blueprint.Package{},
 	}
 	if diff := cmp.Diff(got, expected); diff != "" {
 		t.Fatalf("received unexpected blueprint: %s", diff)
@@ -418,8 +420,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":[],"compose_type":"tar","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":[],"compose_type":"tar","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","accessKeyID":"accesskey","secretAccessKey":"secretkey","bucket":"clay","key":"imagekey"}}]}`},
+		{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":"tar","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":"tar","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","accessKeyID":"accesskey","secretAccessKey":"secretkey","bucket":"clay","key":"imagekey"}}]}`},
 		{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"}]}`},
 	}
diff --git a/test/cases/qcow2_empty_blueprint.json b/test/cases/qcow2_empty_blueprint.json
index 35f34e1b6..af2f83841 100644
--- a/test/cases/qcow2_empty_blueprint.json
+++ b/test/cases/qcow2_empty_blueprint.json
@@ -6,7 +6,7 @@
       "fedora": "sha256:9f596e18f585bee30ac41c11fb11a83ed6b11d5b341c1cb56ca4015d7717cb97"
     },
     "output-format": "qcow2",
-    "filename": "image.qcow2",
+    "filename": "disk.qcow2",
     "blueprint": {}
   },
   "pipeline": {
@@ -116,7 +116,7 @@
       "name": "org.osbuild.qemu",
       "options": {
         "format": "qcow2",
-        "filename": "image.qcow2",
+        "filename": "disk.qcow2",
         "ptuuid": "0x14fc63d2",
         "root_fs_uuid": "76a22bf4-f153-4541-b6c7-0332c0dfaeac",
         "size": 3222274048
diff --git a/test/cases/qcow2_local_boot.json b/test/cases/qcow2_local_boot.json
index 75314feb0..6c12c4dae 100644
--- a/test/cases/qcow2_local_boot.json
+++ b/test/cases/qcow2_local_boot.json
@@ -6,7 +6,7 @@
     "distro": "fedora-30",
     "arch": "x86_64",
     "output-format": "qcow2",
-    "filename": "image.qcow2",
+    "filename": "disk.qcow2",
     "blueprint-draft": {
       "name": "qcow2-boot-test",
       "description": "Image for boot test",
@@ -166,7 +166,7 @@
       "name": "org.osbuild.qemu",
       "options": {
         "format": "qcow2",
-        "filename": "image.qcow2",
+        "filename": "disk.qcow2",
         "ptuuid": "0x14fc63d2",
         "root_fs_uuid": "76a22bf4-f153-4541-b6c7-0332c0dfaeac",
         "size": 3222274048