From 254c10b484256f683fd1f360b05bd733acb07bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Pavl=C3=AD=C4=8Dek?= Date: Fri, 4 Sep 2026 08:52:35 +0200 Subject: [PATCH] seaweed testing, gitea actions --- gitea-actions | 1 + seaweed-testing/.gitignore | 3 ++ seaweed-testing/go.mod | 3 ++ seaweed-testing/go.sum | 0 seaweed-testing/main.go | 56 +++++++++++++++++++++++ seaweed-testing/zerops-service-import.yml | 6 +++ seaweed-testing/zerops.yml | 22 +++++++++ 7 files changed, 91 insertions(+) create mode 160000 gitea-actions create mode 100644 seaweed-testing/.gitignore create mode 100644 seaweed-testing/go.mod create mode 100644 seaweed-testing/go.sum create mode 100644 seaweed-testing/main.go create mode 100644 seaweed-testing/zerops-service-import.yml create mode 100644 seaweed-testing/zerops.yml diff --git a/gitea-actions b/gitea-actions new file mode 160000 index 0000000..4c70a52 --- /dev/null +++ b/gitea-actions @@ -0,0 +1 @@ +Subproject commit 4c70a520d2649532b8723d784c426c860d25f740 diff --git a/seaweed-testing/.gitignore b/seaweed-testing/.gitignore new file mode 100644 index 0000000..67bdb08 --- /dev/null +++ b/seaweed-testing/.gitignore @@ -0,0 +1,3 @@ +node_modules +package-lock.json +app diff --git a/seaweed-testing/go.mod b/seaweed-testing/go.mod new file mode 100644 index 0000000..4e8599c --- /dev/null +++ b/seaweed-testing/go.mod @@ -0,0 +1,3 @@ +module github.com/tikinang/godummy + +go 1.26.5 diff --git a/seaweed-testing/go.sum b/seaweed-testing/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/seaweed-testing/main.go b/seaweed-testing/main.go new file mode 100644 index 0000000..650e466 --- /dev/null +++ b/seaweed-testing/main.go @@ -0,0 +1,56 @@ +package main + +import ( + "crypto/sha256" + "fmt" + "net/http" + "strconv" + "sync" + "time" +) + +var BuildTime string + +const ramChunkSize = 100 * 1024 * 1024 // 0.1 GiB + +var ( + ramMu sync.Mutex + ramChunks [][]byte +) + +func main() { + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + _, _ = fmt.Fprintln(w, BuildTime) + }) + http.HandleFunc("/ram", func(w http.ResponseWriter, r *http.Request) { + chunk := make([]byte, ramChunkSize) + for i := range chunk { + chunk[i] = 1 + } + ramMu.Lock() + ramChunks = append(ramChunks, chunk) + total := len(ramChunks) + ramMu.Unlock() + + w.WriteHeader(http.StatusOK) + _, _ = fmt.Fprintf(w, "allocated 0.1 GiB, total held: %.1f GiB (%d chunks)\n", float64(total)*0.1, total) + }) + http.HandleFunc("/cpu", func(w http.ResponseWriter, r *http.Request) { + iterations := 1_000_000 + if n, err := strconv.Atoi(r.URL.Query().Get("n")); err == nil && n > 0 { + iterations = n + } + + start := time.Now() + sum := sha256.Sum256([]byte("zerops")) + for i := 0; i < iterations; i++ { + sum = sha256.Sum256(sum[:]) + } + elapsed := time.Since(start) + + w.WriteHeader(http.StatusOK) + _, _ = fmt.Fprintf(w, "computed %x in %s (%d iterations)\n", sum, elapsed, iterations) + }) + _ = http.ListenAndServe(":8080", nil) +} diff --git a/seaweed-testing/zerops-service-import.yml b/seaweed-testing/zerops-service-import.yml new file mode 100644 index 0000000..7c380de --- /dev/null +++ b/seaweed-testing/zerops-service-import.yml @@ -0,0 +1,6 @@ +services: + - hostname: app + type: ubuntu@24.04 + maxContainers: 1 + buildFromGit: https://github.com/tikinang/godummy + enableSubdomainAccess: true diff --git a/seaweed-testing/zerops.yml b/seaweed-testing/zerops.yml new file mode 100644 index 0000000..22c942c --- /dev/null +++ b/seaweed-testing/zerops.yml @@ -0,0 +1,22 @@ +zerops: + - setup: test + build: + base: ubuntu/go@latest + buildCommands: + - go build -ldflags "-X main.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o app main.go + cache: true + deployFiles: + - app + run: + base: ubuntu@latest + ports: + - port: 8080 + httpSupport: true + startCommands: + - name: webserver + command: /var/www/app + - name: mount + initCommands: + - sudo mkdir -p /mnt/vol + - sudo chown -R zerops:zerops /mnt/vol + command: sudo /opt/zerops/bin/weed-3-85 mount -filer node-stable-1.db.sharedstorage.zerops:8888 -dir /mnt/vol