Added Tests: web-service, etherpad-service, excalidraw-backend-service, excalidraw-deployment, meapp-development, meapp-fullstack-service

This commit is contained in:
Mirco 2024-08-02 16:17:30 +02:00
parent 0e47be31c6
commit 8f714c3bdd
8 changed files with 109 additions and 12 deletions

View file

@ -83,17 +83,33 @@
(yaml/from-string (yaml/load-resource "jitsi/jvb-service.yaml"))
(cm/replace-all-matching "NAMESPACE" namespace))))
(defn-spec generate-web-service cp/map-or-seq? []
(yaml/load-as-edn "jitsi/web-service.yaml"))
(defn-spec generate-web-service cp/map-or-seq?
[config config?]
(let [{:keys [namespace]} config]
(->
(yaml/load-as-edn "jitsi/web-service.yaml")
(cm/replace-all-matching "NAMESPACE" namespace))))
(defn-spec generate-etherpad-service cp/map-or-seq? []
(yaml/load-as-edn "jitsi/etherpad-service.yaml"))
(defn-spec generate-etherpad-service cp/map-or-seq?
[config config?]
(let [{:keys [namespace]} config]
(->
(yaml/load-as-edn "jitsi/etherpad-service.yaml")
(cm/replace-all-matching "NAMESPACE" namespace))))
(defn-spec generate-excalidraw-backend-service cp/map-or-seq? []
(yaml/load-as-edn "jitsi/excalidraw-backend-service.yaml"))
(defn-spec generate-excalidraw-backend-service cp/map-or-seq?
[config config?]
(let [{:keys [namespace]} config]
(->
(yaml/load-as-edn "jitsi/excalidraw-backend-service.yaml")
(cm/replace-all-matching "NAMESPACE" namespace))))
(defn-spec generate-meapp-fullstack-service cp/map-or-seq? []
(yaml/load-as-edn "jitsi/meapp-fullstack-service.yaml"))
(defn-spec generate-meapp-fullstack-service cp/map-or-seq?
[config config?]
(let [{:keys [namespace]} config]
(->
(yaml/load-as-edn "jitsi/meapp-fullstack-service.yaml")
(cm/replace-all-matching "NAMESPACE" namespace))))
(defn-spec generate-deployment cp/map-or-seq?
[config config?]
@ -108,8 +124,16 @@
(cm/replace-all-matching "REPLACE_EXCALIDRAW_BACKEND_URL"
(str "https://excalidraw-backend." fqdn)))))
(defn-spec generate-excalidraw-deployment cp/map-or-seq? []
(yaml/load-as-edn "jitsi/excalidraw-deployment.yaml"))
(defn-spec generate-excalidraw-deployment cp/map-or-seq?
[config config?]
(let [{:keys [fqdn namespace]} config]
(->
(yaml/load-as-edn "jitsi/excalidraw-deployment.yaml")
(cm/replace-all-matching "NAMESPACE" namespace))))
(defn-spec generate-meapp-deployment cp/map-or-seq? []
(yaml/load-as-edn "jitsi/meapp-deployment.yaml"))
(defn-spec generate-meapp-deployment cp/map-or-seq?
[config config?]
(let [{:keys [fqdn namespace]} config]
(->
(yaml/load-as-edn "jitsi/meapp-deployment.yaml")
(cm/replace-all-matching "NAMESPACE" namespace))))

View file

@ -4,6 +4,7 @@ metadata:
labels:
service: etherpad
name: etherpad
namespace: NAMESPACE
spec:
ports:
- name: etherpad

View file

@ -4,6 +4,7 @@ metadata:
labels:
service: excalidraw-backend
name: excalidraw-backend
namespace: NAMESPACE
spec:
ports:
- name: excalidraw-backend

View file

@ -4,6 +4,7 @@ metadata:
labels:
app: excalidraw-backend
name: excalidraw-backend
namespace: NAMESPACE
spec:
strategy:
type: Recreate

View file

@ -4,6 +4,7 @@ metadata:
labels:
app: meapp-fullstack
name: meapp-fullstack
namespace: NAMESPACE
spec:
replicas: 1
strategy:

View file

@ -4,6 +4,7 @@ metadata:
labels:
service: meapp-fullstack
name: meapp-fullstack
namespace: NAMESPACE
spec:
ports:
- name: "http"

View file

@ -4,6 +4,7 @@ metadata:
labels:
service: web
name: web
namespace: NAMESPACE
spec:
ports:
- name: "http"

View file

@ -168,3 +168,70 @@
(cut/generate-jvb-service
{:fqdn "xy.xy.xy"
:namespace "jitsi"}))))
(deftest should-generate-web-service
(is (= {:apiVersion "v1",
:kind "Service",
:metadata {:labels {:service "web"}, :name "web", :namespace "jitsi"},
:spec
{:ports
[{:name "http", :port 80, :targetPort 80}
{:name "https", :port 443, :targetPort 443}],
:selector {:app "jitsi"}}}
(cut/generate-web-service
{:fqdn "xy.xy.xy"
:namespace "jitsi"}))))
(deftest should-generate-etherpad-service
(is (= {:apiVersion "v1",
:kind "Service",
:metadata
{:labels {:service "etherpad"}, :name "etherpad", :namespace "jitsi"},
:spec
{:ports [{:name "etherpad", :port 9001, :targetPort 9001}],
:selector {:app "jitsi"}}}
(cut/generate-etherpad-service
{:fqdn "xy.xy.xy"
:namespace "jitsi"}))))
(deftest should-generate-excalidraw-backend-service
(is (= {:apiVersion "v1",
:kind "Service",
:metadata
{:labels {:service "excalidraw-backend"},
:name "excalidraw-backend",
:namespace "jitsi"},
:spec
{:ports [{:name "excalidraw-backend", :port 3002, :targetPort 80}],
:selector {:app "excalidraw-backend"}}}
(cut/generate-excalidraw-backend-service
{:fqdn "xy.xy.xy"
:namespace "jitsi"}))))
(deftest should-generate-meapp-fullstack-service
(is (= {:apiVersion "v1",
:kind "Service",
:metadata
{:labels {:service "excalidraw-backend"},
:name "excalidraw-backend",
:namespace "jitsi"},
:spec
{:ports [{:name "excalidraw-backend", :port 3002, :targetPort 80}],
:selector {:app "excalidraw-backend"}}}
(cut/generate-excalidraw-backend-service
{:fqdn "xy.xy.xy"
:namespace "jitsi"}))))
(deftest should-generate-excalidraw-deployment
(is (= {:apiVersion "v1",
:kind "Service",
:metadata
{:labels {:service "excalidraw-backend"},
:name "excalidraw-backend",
:namespace "jitsi"},
:spec
{:ports [{:name "excalidraw-backend", :port 3002, :targetPort 80}],
:selector {:app "excalidraw-backend"}}}
(cut/generate-excalidraw-backend-service
{:fqdn "xy.xy.xy"
:namespace "jitsi"}))))