Add Emberwake Cloud Ecosystem deploy hub with AWS and generic spread templates.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Unified expandable panels with mermaid flows, ZIP export, connection tests, and Playwright smoke coverage.
This commit is contained in:
72
server/internal/api/cloud_spread_test.go
Normal file
72
server/internal/api/cloud_spread_test.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExportCloudTemplateZIP(t *testing.T) {
|
||||
root := integrationWorkspaceRoot(t)
|
||||
h := NewSpreadHandler(nil, t.TempDir(), root, nil)
|
||||
body, _ := json.Marshal(map[string]interface{}{
|
||||
"template": "curl-manifest",
|
||||
"server_url": "https://deck.example",
|
||||
"build_id": "pin-cloud",
|
||||
"campaign": "aws-wave",
|
||||
"bucket": "lab-shards",
|
||||
"cloudfront_domain": "d111.cloudfront.net",
|
||||
"minio_endpoint": "https://minio.lab:9000",
|
||||
"region": "us-west-2",
|
||||
})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/v1/builder/cloud-template-export", bytes.NewReader(body))
|
||||
rec := httptest.NewRecorder()
|
||||
h.ExportCloudTemplate(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
entries := readZipEntries(t, rec.Body.Bytes())
|
||||
if !strings.Contains(entries["manifest.json"], "https://deck.example") {
|
||||
t.Fatalf("manifest.json: %s", entries["manifest.json"])
|
||||
}
|
||||
if !strings.Contains(entries["manifest.json"], "pin-cloud") {
|
||||
t.Fatalf("expected build pin in manifest: %s", entries["manifest.json"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestExportCloudTemplateRequiresServerURL(t *testing.T) {
|
||||
root := integrationWorkspaceRoot(t)
|
||||
h := NewSpreadHandler(nil, t.TempDir(), root, nil)
|
||||
body, _ := json.Marshal(map[string]string{"template": "minio"})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/v1/builder/cloud-template-export", bytes.NewReader(body))
|
||||
rec := httptest.NewRecorder()
|
||||
h.ExportCloudTemplate(rec, req)
|
||||
if rec.Code != http.StatusBadRequest {
|
||||
t.Fatalf("status %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloudConnectionTestHTTP(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
defer srv.Close()
|
||||
h := NewSpreadHandler(nil, t.TempDir(), ".", nil)
|
||||
body, _ := json.Marshal(map[string]string{"kind": "http", "endpoint": srv.URL})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/v1/builder/cloud-connection-test", bytes.NewReader(body))
|
||||
rec := httptest.NewRecorder()
|
||||
h.TestCloudConnection(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status %d: %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
var resp cloudConnectionTestResponse
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !resp.OK || !resp.Reachable {
|
||||
t.Fatalf("resp=%+v", resp)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user