diff --git a/.gitignore b/.gitignore index 83c4f76a5..1122ff039 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,5 @@ __pycache__ /osbuild-dnf-json-tests /osbuild-tests /osbuild-weldr-tests -/osbuild-rcm-tests /rpmbuild diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bfc352d06..169cae350 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,7 +74,7 @@ The commits in the PR should have these properties: obviously wrong * Well documented: both code and commit message * The commit message should start with the module you work on, - like: `weldr: `, or `rcm:` + like: `weldr: `, or `distro:` * The code should compile and the composer should start, so that we can run `git bisect` on it * All code should be covered by unit-tests diff --git a/Makefile b/Makefile index b94cb40d6..f777ea9e0 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,6 @@ build: go test -c -tags=integration -o osbuild-tests ./cmd/osbuild-tests/main_test.go go test -c -tags=integration -o osbuild-weldr-tests ./internal/client/ go test -c -tags=integration -o osbuild-dnf-json-tests ./cmd/osbuild-dnf-json-tests/main_test.go - go test -c -tags=integration -o osbuild-rcm-tests ./cmd/osbuild-rcm-tests/main_test.go go test -c -tags=integration,travis -o osbuild-image-tests ./cmd/osbuild-image-tests/ .PHONY: install diff --git a/cmd/osbuild-composer/main.go b/cmd/osbuild-composer/main.go index f8bcf2689..936ca1e79 100644 --- a/cmd/osbuild-composer/main.go +++ b/cmd/osbuild-composer/main.go @@ -13,7 +13,6 @@ import ( "github.com/osbuild/osbuild-composer/internal/distro/fedora32" "github.com/osbuild/osbuild-composer/internal/distro/rhel8" "github.com/osbuild/osbuild-composer/internal/jobqueue/fsjobqueue" - "github.com/osbuild/osbuild-composer/internal/rcm" "github.com/osbuild/osbuild-composer/internal/common" "github.com/osbuild/osbuild-composer/internal/distro" @@ -143,22 +142,6 @@ func main() { common.PanicOnError(err) }() - // Optionally run RCM API as well as Weldr API - if rcmApiListeners, exists := listeners["osbuild-rcm.socket"]; exists { - if len(rcmApiListeners) != 1 { - // Use Fatal to call os.Exit with non-zero return value - log.Fatal("The RCM API socket unit is misconfigured. It should contain only one socket.") - } - rcmListener := rcmApiListeners[0] - rcmAPI := rcm.New(logger, workers, rpm, distros) - go func() { - err := rcmAPI.Serve(rcmListener) - // If the RCM API fails, take down the whole process, not just a single gorutine - log.Fatal("RCM API failed: ", err) - }() - - } - if remoteWorkerListeners, exists := listeners["osbuild-remote-worker.socket"]; exists { for _, listener := range remoteWorkerListeners { log.Printf("Starting remote listener\n") diff --git a/cmd/osbuild-rcm-tests/main_test.go b/cmd/osbuild-rcm-tests/main_test.go deleted file mode 100644 index 2e9d7a9e4..000000000 --- a/cmd/osbuild-rcm-tests/main_test.go +++ /dev/null @@ -1,69 +0,0 @@ -// osbuild-rcm-tests run tests against running osbuild-composer instance that was spawned using the -// osbuild-rcm.socket unit. It defines the expected use cases of the RCM API. - -// +build integration - -package main - -import ( - "encoding/json" - "net/http" - "strings" - "testing" - - "github.com/google/uuid" - "github.com/stretchr/testify/require" -) - -func TestRCM(t *testing.T) { - // This is the first request the user sends to osbuild. - submitBody := ` - { - "image_builds": - [ - { - "distribution": "fedora-31", - "architecture": "x86_64", - "image_type": "qcow2", - "repositories": - [ - { - "baseurl": "http://download.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/" - } - ] - } - ] - } - ` - // This is what the user gets back. - var submitResponse struct { - UUID uuid.UUID `json:"compose_id"` - } - // Then it is possible to get the status on the /v1/compose/ endpoint. - // And finally this is the response from getting the status. - var statusResponse struct { - Status string `json:"status"` - } - - // osbuild instance running on localhost - socket := "http://127.0.0.1:80/" - endpoint := "v1/compose" - - // Case 1: POST request - - resp, err := http.Post(socket+endpoint, "application/json", strings.NewReader(submitBody)) - require.Nilf(t, err, "Failed to submit a compose: %v", err) - require.Equalf(t, resp.StatusCode, 200, "Error: the %v returned non 200 status. Full response: %v", endpoint, resp) - err = json.NewDecoder(resp.Body).Decode(&submitResponse) - require.Nilf(t, err, "Failed to decode JSON response from %v", endpoint) - - // Case 2: GET status - - statusEndpoint := endpoint + "/" + submitResponse.UUID.String() - resp, err = http.Get(socket + statusEndpoint) - require.Nilf(t, err, "Failed to get a status: %v", err) - require.Equalf(t, resp.StatusCode, 200, "Error: the %v returned non 200 status. Full response: %v", endpoint, resp) - err = json.NewDecoder(resp.Body).Decode(&statusResponse) - require.Nilf(t, err, "Failed to decode JSON response from %v", endpoint) - -} diff --git a/distribution/osbuild-rcm.socket b/distribution/osbuild-rcm.socket deleted file mode 100644 index 8b8055a93..000000000 --- a/distribution/osbuild-rcm.socket +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=OSBuild Composer RCM API socket - -[Socket] -Service=osbuild-composer.service -ListenStream=80 - -[Install] -WantedBy=sockets.target diff --git a/golang-github-osbuild-composer.spec b/golang-github-osbuild-composer.spec index 5de316ea8..e2b6af95d 100644 --- a/golang-github-osbuild-composer.spec +++ b/golang-github-osbuild-composer.spec @@ -92,7 +92,6 @@ TEST_LDFLAGS="${LDFLAGS:-} -B 0x$(od -N 20 -An -tx1 -w100 /dev/urandom | tr -d ' go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-tests %{goipath}/cmd/osbuild-tests go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-dnf-json-tests %{goipath}/cmd/osbuild-dnf-json-tests go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-weldr-tests %{goipath}/internal/client/ -go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-rcm-tests %{goipath}/cmd/osbuild-rcm-tests go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-image-tests %{goipath}/cmd/osbuild-image-tests %install @@ -117,7 +116,6 @@ install -m 0755 -vp _bin/osbuild-tests %{buildroot}%{_libex install -m 0755 -vp _bin/osbuild-weldr-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ install -m 0755 -vp _bin/osbuild-dnf-json-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ install -m 0755 -vp _bin/osbuild-image-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ -install -m 0755 -vp _bin/osbuild-rcm-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ install -m 0755 -vp tools/image-info %{buildroot}%{_libexecdir}/osbuild-composer/ install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer @@ -160,25 +158,6 @@ export GOPATH=$PWD/_build:%{gopath} %{_unitdir}/osbuild-remote-worker.socket %{_sysusersdir}/osbuild-composer.conf -%package rcm -Summary: RCM-specific version of osbuild-composer -Requires: %{name} = %{version}-%{release} - -%description rcm -RCM-specific version of osbuild-composer not intended for public usage. - -%files rcm -%{_unitdir}/osbuild-rcm.socket - -%post rcm -%systemd_post osbuild-rcm.socket - -%preun rcm -%systemd_preun osbuild-rcm.socket - -%postun rcm -%systemd_postun_with_restart osbuild-rcm.socket - %package worker Summary: The worker for osbuild-composer Requires: systemd @@ -211,7 +190,6 @@ systemctl stop "osbuild-worker@*.service" "osbuild-remote-worker@*.service" %package tests Summary: Integration tests Requires: %{name} = %{version}-%{release} -Requires: %{name}-rcm = %{version}-%{release} Requires: composer-cli Requires: createrepo_c Requires: genisoimage diff --git a/internal/rcm/api.go b/internal/rcm/api.go deleted file mode 100644 index 0cca0860e..000000000 --- a/internal/rcm/api.go +++ /dev/null @@ -1,277 +0,0 @@ -// Package rcm provides alternative HTTP API to Weldr. -// It's primary use case is for the RCM team. As such it is driven solely by their requirements. -package rcm - -import ( - "encoding/json" - "fmt" - "log" - "net" - "net/http" - - "github.com/osbuild/osbuild-composer/internal/blueprint" - "github.com/osbuild/osbuild-composer/internal/rpmmd" - "github.com/osbuild/osbuild-composer/internal/worker" - - "github.com/google/uuid" - "github.com/julienschmidt/httprouter" - "github.com/osbuild/osbuild-composer/internal/distro" -) - -// API encapsulates RCM-specific API that is exposed over a separate TCP socket -type API struct { - logger *log.Logger - workers *worker.Server - router *httprouter.Router - // rpmMetadata is an interface to dnf-json and we include it here so that we can - // mock it in the unit tests - rpmMetadata rpmmd.RPMMD - distros *distro.Registry -} - -// New creates new RCM API -func New(logger *log.Logger, workers *worker.Server, rpmMetadata rpmmd.RPMMD, distros *distro.Registry) *API { - api := &API{ - logger: logger, - workers: workers, - router: httprouter.New(), - rpmMetadata: rpmMetadata, - distros: distros, - } - - api.router.RedirectTrailingSlash = false - api.router.RedirectFixedPath = false - api.router.MethodNotAllowed = http.HandlerFunc(methodNotAllowedHandler) - api.router.NotFound = http.HandlerFunc(notFoundHandler) - - api.router.POST("/v1/compose", api.submit) - api.router.GET("/v1/compose/:uuid", api.status) - - return api -} - -// Serve serves the RCM API over the provided listener socket -func (api *API) Serve(listener net.Listener) error { - server := http.Server{Handler: api} - - err := server.Serve(listener) - if err != nil && err != http.ErrServerClosed { - return err - } - - return nil -} - -// ServeHTTP logs the request, sets content-type, and forwards the request to appropriate handler -func (api *API) ServeHTTP(writer http.ResponseWriter, request *http.Request) { - if api.logger != nil { - log.Println(request.Method, request.URL.Path) - } - - writer.Header().Set("Content-Type", "application/json; charset=utf-8") - api.router.ServeHTTP(writer, request) -} - -func methodNotAllowedHandler(writer http.ResponseWriter, request *http.Request) { - writer.WriteHeader(http.StatusMethodNotAllowed) -} - -func notFoundHandler(writer http.ResponseWriter, request *http.Request) { - writer.WriteHeader(http.StatusNotFound) -} - -// Depsolves packages and build packages for building an image for a given -// distro, in the given architecture -func depsolve(rpmmd rpmmd.RPMMD, distro distro.Distro, imageType distro.ImageType, repos []rpmmd.RepoConfig, arch distro.Arch) ([]rpmmd.PackageSpec, []rpmmd.PackageSpec, error) { - specs, excludeSpecs := imageType.Packages(blueprint.Blueprint{}) - packages, _, err := rpmmd.Depsolve(specs, excludeSpecs, repos, distro.ModulePlatformID(), arch.Name()) - if err != nil { - return nil, nil, fmt.Errorf("RPMMD.Depsolve: %v", err) - } - - specs = imageType.BuildPackages() - buildPackages, _, err := rpmmd.Depsolve(specs, nil, repos, distro.ModulePlatformID(), arch.Name()) - if err != nil { - return nil, nil, fmt.Errorf("RPMMD.Depsolve: %v", err) - } - - return packages, buildPackages, err -} - -func (api *API) submit(writer http.ResponseWriter, request *http.Request, _ httprouter.Params) { - // Check some basic HTTP parameters - contentType := request.Header["Content-Type"] - if len(contentType) != 1 || contentType[0] != "application/json" { - writer.WriteHeader(http.StatusBadRequest) - return - } - - type repository struct { - BaseURL string `json:"baseurl,omitempty"` - Metalink string `json:"metalink,omitempty"` - MirrorList string `json:"mirrorlist,omitempty"` - GPGKey string `json:"gpgkey,omitempty"` - } - - type imageBuild struct { - Distribution string `json:"distribution"` - Architecture string `json:"architecture"` - ImageType string `json:"image_type"` - Repositories []repository `json:"repositories"` - } - - // JSON structure expected from the client - var composeRequest struct { - ImageBuilds []imageBuild `json:"image_builds"` - } - // JSON structure with error message - var errorReason struct { - Error string `json:"error_reason"` - } - // Parse and verify the structure - decoder := json.NewDecoder(request.Body) - decoder.DisallowUnknownFields() - err := decoder.Decode(&composeRequest) - if err != nil { - writer.WriteHeader(http.StatusBadRequest) - err = json.NewEncoder(writer).Encode(err.Error()) - if err != nil { - panic("Failed to write response") - } - return - } - - if len(composeRequest.ImageBuilds) != 1 { - writer.WriteHeader(http.StatusBadRequest) - _, err := writer.Write([]byte("unsupported number of image builds")) - if err != nil { - panic("Failed to write response") - } - return - } - - buildRequest := composeRequest.ImageBuilds[0] - - d := api.distros.GetDistro(buildRequest.Distribution) - if d == nil { - writer.WriteHeader(http.StatusBadRequest) - _, err := writer.Write([]byte("unknown distro")) - if err != nil { - panic("Failed to write response") - } - return - } - - arch, err := d.GetArch(buildRequest.Architecture) - if err != nil { - writer.WriteHeader(http.StatusBadRequest) - _, err := writer.Write([]byte("unknown architecture for distro")) - if err != nil { - panic("Failed to write response") - } - return - } - - imageType, err := arch.GetImageType(buildRequest.ImageType) - if err != nil { - writer.WriteHeader(http.StatusBadRequest) - _, err := writer.Write([]byte("unknown image type for distro and architecture")) - if err != nil { - panic("Failed to write response") - } - return - } - - // Create repo configurations from the URLs in the request. - repoConfigs := []rpmmd.RepoConfig{} - for n, repo := range buildRequest.Repositories { - repoConfigs = append(repoConfigs, rpmmd.RepoConfig{ - Name: fmt.Sprintf("repo-%d", n), - BaseURL: repo.BaseURL, - Metalink: repo.Metalink, - MirrorList: repo.MirrorList, - GPGKey: repo.GPGKey, - }) - } - - packages, buildPackages, err := depsolve(api.rpmMetadata, d, imageType, repoConfigs, arch) - if err != nil { - writer.WriteHeader(http.StatusBadRequest) - _, err := writer.Write([]byte(err.Error())) - if err != nil { - panic("Failed to write response") - } - return - } - - manifest, err := imageType.Manifest(nil, - distro.ImageOptions{ - Size: imageType.Size(0), - }, - repoConfigs, - packages, - buildPackages) - if err != nil { - writer.WriteHeader(http.StatusBadRequest) - _, err := writer.Write([]byte(err.Error())) - if err != nil { - panic("Failed to write response") - } - return - } - - composeID, err := api.workers.Enqueue(manifest, nil) - if err != nil { - if api.logger != nil { - api.logger.Println("RCM API failed to push compose:", err) - } - writer.WriteHeader(http.StatusBadRequest) - errorReason.Error = "failed to push compose: " + err.Error() - // TODO: handle error - _ = json.NewEncoder(writer).Encode(errorReason) - return - } - - // Create the response JSON structure - var reply struct { - UUID uuid.UUID `json:"compose_id"` - } - reply.UUID = composeID - // TODO: handle error - _ = json.NewEncoder(writer).Encode(reply) -} - -func (api *API) status(writer http.ResponseWriter, request *http.Request, params httprouter.Params) { - // JSON structure in case of error - var errorReason struct { - Error string `json:"error_reason"` - } - // Check that the input is a valid UUID - uuidParam := params.ByName("uuid") - id, err := uuid.Parse(uuidParam) - if err != nil { - writer.WriteHeader(http.StatusBadRequest) - errorReason.Error = "Malformed UUID" - // TODO: handle error - _ = json.NewEncoder(writer).Encode(errorReason) - return - } - - // Check that the compose exists - status, err := api.workers.JobStatus(id) - if err != nil { - writer.WriteHeader(http.StatusBadRequest) - errorReason.Error = err.Error() - // TODO: handle error - _ = json.NewEncoder(writer).Encode(errorReason) - return - } - - // JSON structure with success response - type reply struct { - Status string `json:"status"` - } - - // TODO: handle error - _ = json.NewEncoder(writer).Encode(reply{Status: status.State.ToString()}) -} diff --git a/internal/rcm/api_test.go b/internal/rcm/api_test.go deleted file mode 100644 index 6c0b96d0b..000000000 --- a/internal/rcm/api_test.go +++ /dev/null @@ -1,311 +0,0 @@ -package rcm_test - -import ( - "bytes" - "encoding/json" - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "regexp" - "testing" - - "github.com/google/uuid" - "github.com/stretchr/testify/require" - - "github.com/osbuild/osbuild-composer/internal/jobqueue/testjobqueue" - distro_mock "github.com/osbuild/osbuild-composer/internal/mocks/distro" - rpmmd_mock "github.com/osbuild/osbuild-composer/internal/mocks/rpmmd" - "github.com/osbuild/osbuild-composer/internal/rcm" - "github.com/osbuild/osbuild-composer/internal/worker" -) - -type API interface { - ServeHTTP(writer http.ResponseWriter, request *http.Request) -} - -func internalRequest(api API, method, path, body, contentType string) *http.Response { - req := httptest.NewRequest(method, path, bytes.NewReader([]byte(body))) - req.Header.Set("Content-Type", contentType) - resp := httptest.NewRecorder() - api.ServeHTTP(resp, req) - - return resp.Result() -} - -func newTestWorkerServer(t *testing.T) (*worker.Server, string) { - dir, err := ioutil.TempDir("", "rcm-test-") - require.NoError(t, err) - - w := worker.NewServer(nil, testjobqueue.New(), "") - require.NotNil(t, w) - - return w, dir -} - -func cleanupTempDir(t *testing.T, dir string) { - err := os.RemoveAll(dir) - require.NoError(t, err) -} - -func TestBasicRcmAPI(t *testing.T) { - // Test the HTTP API responses - // This test mainly focuses on HTTP status codes and JSON structures, not necessarily on their content - - var cases = []struct { - Method string - Path string - Body string - ContentType string - ExpectedStatus int - ExpectedBodyRegex string - }{ - {"GET", "/v1/compose", ``, "", http.StatusMethodNotAllowed, ``}, - {"POST", "/v1/compose", `{"status":"RUNNING"}`, "application/json", http.StatusBadRequest, ``}, - {"POST", "/v1/compose", `{"status":"RUNNING"}`, "text/plain", http.StatusBadRequest, ``}, - {"POST", "/v1/compose", `{"image_builds":[]}`, "application/json", http.StatusBadRequest, ""}, - {"POST", "/v1/compose/111-222-333", `{"status":"RUNNING"}`, "application/json", http.StatusMethodNotAllowed, ``}, - {"GET", "/v1/compose/7802c476-9cd1-41b7-ba81-43c1906bce73", `{"status":"RUNNING"}`, "application/json", http.StatusBadRequest, ``}, - } - - registry, err := distro_mock.NewDefaultRegistry() - if err != nil { - t.Fatal(err) - } - - workers, dir := newTestWorkerServer(t) - defer cleanupTempDir(t, dir) - - api := rcm.New(nil, workers, rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()), registry) - - for _, c := range cases { - resp := internalRequest(api, c.Method, c.Path, c.Body, c.ContentType) - buf := new(bytes.Buffer) - _, _ = buf.ReadFrom(resp.Body) - response_body := buf.String() - if resp.StatusCode != c.ExpectedStatus { - t.Errorf("%s request to %s should return status code %d but returns %d, response: %s", c.Method, c.Path, c.ExpectedStatus, resp.StatusCode, response_body) - } - matched, err := regexp.Match(c.ExpectedBodyRegex, []byte(response_body)) - if err != nil { - t.Fatalf("Failed to match regex, correct the test definition!") - } - if !matched { - t.Errorf("The response to %s request to %s should match this regex %s but returns %s", c.Method, c.Path, c.ExpectedBodyRegex, response_body) - } - } -} - -func TestSubmit(t *testing.T) { - registry, err := distro_mock.NewDefaultRegistry() - if err != nil { - t.Fatal(err) - } - - workers, dir := newTestWorkerServer(t) - defer cleanupTempDir(t, dir) - - api := rcm.New(nil, workers, rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()), registry) - - var submit_reply struct { - UUID uuid.UUID `json:"compose_id"` - } - - var cases = []struct { - Method string - Path string - Body string - ContentType string - ExpectedStatus int - }{ - { - "POST", - "/v1/compose", - `{ - "image_builds": - [ - { - "distribution": "fedora-30", - "architecture": "x86_64", - "image_type": "qcow2", - "repositories": - [ - { - "baseurl": "http://mirrors.kernel.org/fedora/releases/30/Everything/x86_64/os/" - } - ] - } - ] - }`, - "application/json", - http.StatusOK, - }, - { - "POST", - "/v1/compose", - `{ - "image_builds": - [ - { - "distribution": "invalid", - "architecture": "x86_64", - "image_type": "qcow2", - "repositories": - [ - { - "baseurl": "http://mirrors.kernel.org/fedora/releases/30/Everything/x86_64/os/" - } - ] - } - ] - }`, - "application/json", - http.StatusBadRequest, - }, - { - "POST", - "/v1/compose", - `{ - "image_builds": - [ - { - "distribution": "fedora-30", - "architecture": "invalid", - "image_type": "qcow2", - "repositories": - [ - { - "baseurl": "http://mirrors.kernel.org/fedora/releases/30/Everything/x86_64/os/" - } - ] - } - ] - }`, - "application/json", - http.StatusBadRequest, - }, - { - "POST", - "/v1/compose", - `{ - "image_builds": - [ - { - "distribution": "fedora-30", - "architecture": "x86_64", - "image_type": "invalid", - "repositories": - [ - { - "baseurl": "http://mirrors.kernel.org/fedora/releases/30/Everything/x86_64/os/" - } - ] - } - ] - }`, - "application/json", - http.StatusBadRequest, - }, - } - - for n, c := range cases { - // Submit job - t.Logf("RCM API submit compose, case %d\n", n) - resp := internalRequest(api, c.Method, c.Path, c.Body, c.ContentType) - if resp.StatusCode != c.ExpectedStatus { - errReason, _ := ioutil.ReadAll(resp.Body) - t.Fatal("Failed to call /v1/compose, HTTP status code: ", resp.StatusCode, "Error message: ", string(errReason)) - } - if resp.StatusCode == http.StatusOK { - decoder := json.NewDecoder(resp.Body) - decoder.DisallowUnknownFields() - err := decoder.Decode(&submit_reply) - if err != nil { - t.Fatal("Failed to decode response to /v1/compose:", err) - } - } - } -} - -func TestStatus(t *testing.T) { - // Test the most basic use case: Submit a new job and get its status. - registry, err := distro_mock.NewDefaultRegistry() - if err != nil { - t.Fatal(err) - } - - workers, dir := newTestWorkerServer(t) - defer cleanupTempDir(t, dir) - - api := rcm.New(nil, workers, rpmmd_mock.NewRPMMDMock(rpmmd_mock.BaseFixture()), registry) - - var submit_reply struct { - UUID uuid.UUID `json:"compose_id"` - } - var status_reply struct { - Status string `json:"status,omitempty"` - ErrorReason string `json:"error_reason,omitempty"` - } - // Submit a job - resp := internalRequest(api, - "POST", - "/v1/compose", - `{ - "image_builds": - [ - { - "distribution": "fedora-30", - "architecture": "x86_64", - "image_type": "qcow2", - "repositories": - [ - { - "baseurl": "http://mirrors.kernel.org/fedora/releases/30/Everything/x86_64/os/" - } - ] - } - ] - }`, - "application/json") - if resp.StatusCode != http.StatusOK { - errReason, _ := ioutil.ReadAll(resp.Body) - t.Fatal("Failed to call /v1/compose, HTTP status code: ", resp.StatusCode, "Error message: ", string(errReason)) - } - decoder := json.NewDecoder(resp.Body) - decoder.DisallowUnknownFields() - err = decoder.Decode(&submit_reply) - if err != nil { - t.Fatal("Failed to decode response to /v1/compose:", err) - } - - var cases = []struct { - Method string - Path string - Body string - ContentType string - ExpectedStatus string - }{ - { - "GET", - "/v1/compose/" + submit_reply.UUID.String(), - ``, - "application/json", - "WAITING", - }, - } - - for n, c := range cases { - // Get the status - t.Logf("RCM API get compose status, case %d\n", n) - resp = internalRequest(api, c.Method, c.Path, c.Body, c.ContentType) - decoder = json.NewDecoder(resp.Body) - decoder.DisallowUnknownFields() - err = decoder.Decode(&status_reply) - if err != nil { - t.Fatal("Failed to decode response to /v1/compose/UUID:", err) - } - if status_reply.Status != c.ExpectedStatus { - t.Error("Failed to get compose status:", status_reply.Status) - } - } -} diff --git a/osbuild b/osbuild index c1a98af56..1800f2a71 160000 --- a/osbuild +++ b/osbuild @@ -1 +1 @@ -Subproject commit c1a98af56acf376f2b83f6b4f8ae7c984b03f5be +Subproject commit 1800f2a71169a3b8d48a48c07cc66f889352ba0e diff --git a/osbuild-composer.spec b/osbuild-composer.spec index c687ff320..586da059c 100644 --- a/osbuild-composer.spec +++ b/osbuild-composer.spec @@ -107,7 +107,6 @@ TEST_LDFLAGS="${LDFLAGS:-} -B 0x$(od -N 20 -An -tx1 -w100 /dev/urandom | tr -d ' go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-tests %{goipath}/cmd/osbuild-tests go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-dnf-json-tests %{goipath}/cmd/osbuild-dnf-json-tests go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-weldr-tests %{goipath}/internal/client/ -go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-rcm-tests %{goipath}/cmd/osbuild-rcm-tests go test -c -tags=integration -ldflags="${TEST_LDFLAGS}" -o _bin/osbuild-image-tests %{goipath}/cmd/osbuild-image-tests %endif @@ -136,7 +135,6 @@ install -m 0755 -vp _bin/osbuild-tests %{buildroot}%{_libex install -m 0755 -vp _bin/osbuild-weldr-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ install -m 0755 -vp _bin/osbuild-dnf-json-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ install -m 0755 -vp _bin/osbuild-image-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ -install -m 0755 -vp _bin/osbuild-rcm-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/ install -m 0755 -vp tools/image-info %{buildroot}%{_libexecdir}/osbuild-composer/ install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer @@ -181,29 +179,6 @@ export GOPATH=$PWD/_build:%{gopath} %{_unitdir}/osbuild-remote-worker.socket %{_sysusersdir}/osbuild-composer.conf -%package rcm -Summary: RCM-specific version of osbuild-composer -Requires: %{name} = %{version}-%{release} - -# remove in F34 -Obsoletes: golang-github-osbuild-composer-rcm < %{version}-%{release} -Provides: golang-github-osbuild-composer-rcm = %{version}-%{release} - -%description rcm -RCM-specific version of osbuild-composer not intended for public usage. - -%files rcm -%{_unitdir}/osbuild-rcm.socket - -%post rcm -%systemd_post osbuild-rcm.socket - -%preun rcm -%systemd_preun osbuild-rcm.socket - -%postun rcm -%systemd_postun_with_restart osbuild-rcm.socket - %package worker Summary: The worker for osbuild-composer Requires: systemd @@ -242,7 +217,6 @@ systemctl stop "osbuild-worker@*.service" "osbuild-remote-worker@*.service" %package tests Summary: Integration tests Requires: %{name} = %{version}-%{release} -Requires: %{name}-rcm = %{version}-%{release} Requires: composer-cli Requires: createrepo_c Requires: genisoimage diff --git a/schutzbot/deploy.sh b/schutzbot/deploy.sh index 21cd26e5e..1a031e240 100755 --- a/schutzbot/deploy.sh +++ b/schutzbot/deploy.sh @@ -69,9 +69,8 @@ if [[ "${ID}${VERSION_ID//./}" == rhel82 ]]; then fi # Start services. -sudo systemctl enable --now osbuild-rcm.socket sudo systemctl enable --now osbuild-composer.socket # Verify that the API is running. sudo composer-cli status show -sudo composer-cli sources list \ No newline at end of file +sudo composer-cli sources list diff --git a/schutzbot/run_base_tests.sh b/schutzbot/run_base_tests.sh index e3afbd580..648be388e 100755 --- a/schutzbot/run_base_tests.sh +++ b/schutzbot/run_base_tests.sh @@ -8,7 +8,6 @@ PASSED_TESTS=() FAILED_TESTS=() TEST_CASES=( - "osbuild-rcm-tests" "osbuild-weldr-tests" "osbuild-dnf-json-tests" "osbuild-tests" @@ -61,4 +60,4 @@ if [ ${#FAILED_TESTS[@]} -eq 0 ]; then else echo "🔥 One or more tests failed." exit 1 -fi \ No newline at end of file +fi diff --git a/schutzbot/vars.yml b/schutzbot/vars.yml index 7fe0779ac..47c62c802 100644 --- a/schutzbot/vars.yml +++ b/schutzbot/vars.yml @@ -12,7 +12,6 @@ polling_interval: 15 ## Non-image test variables. # List of base tests osbuild_composer_base_tests: - - osbuild-rcm-tests - osbuild-weldr-tests - osbuild-dnf-json-tests - osbuild-tests @@ -34,4 +33,4 @@ osbuild_composer_image_test_cases: - vmdk-boot.json # Environment variables for image tests. -osbuild_composer_image_env_vars: {} \ No newline at end of file +osbuild_composer_image_env_vars: {}