feat: complete Loki query, insights, settings and deployment workflows
Add the Loki query UI, access policies, ingress insights, alert and registry settings, and their backend APIs. Include the related Kubernetes deployment and collector updates required by the integrated application. Validated with go test ./..., npm run build, and npm run lint.
This commit is contained in:
1 parent
f9c6c1d826
commit
2d73661dd1
127 files changed
+8117
-2876
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"opsxloki/models"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClusterWorkloadSelectorsUseSelectedNamespace(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
switch r.URL.Path {
|
||||
case "/api/v1/namespaces":
|
||||
fmt.Fprint(w, `{"apiVersion":"v1","kind":"NamespaceList","items":[{"metadata":{"name":"prod"}},{"metadata":{"name":"default"}}]}`)
|
||||
case "/apis/apps/v1/namespaces/prod/deployments":
|
||||
fmt.Fprint(w, `{"apiVersion":"apps/v1","kind":"DeploymentList","items":[{"metadata":{"name":"api"},"spec":{"replicas":3},"status":{"readyReplicas":2}}]}`)
|
||||
default:
|
||||
t.Errorf("unexpected Kubernetes API path %s", r.URL.Path)
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
cluster := &models.Cluster{KubeConfig: fmt.Sprintf("apiVersion: v1\nkind: Config\nclusters:\n- name: test\n cluster:\n server: %s\ncontexts:\n- name: test\n context:\n cluster: test\n user: test\ncurrent-context: test\nusers:\n- name: test\n user: {}\n", server.URL)}
|
||||
namespaces, err := ListClusterNamespaces(context.Background(), cluster)
|
||||
if err != nil || len(namespaces) != 2 || namespaces[0] != "default" || namespaces[1] != "prod" {
|
||||
t.Fatalf("unexpected namespaces: %v, %v", namespaces, err)
|
||||
}
|
||||
deployments, err := ListClusterDeployments(context.Background(), cluster, "prod")
|
||||
if err != nil || len(deployments) != 1 || deployments[0].Name != "api" || deployments[0].Replicas != 3 || deployments[0].ReadyReplicas != 2 {
|
||||
t.Fatalf("unexpected deployments: %v, %v", deployments, err)
|
||||
}
|
||||
if _, err := ListClusterDeployments(context.Background(), cluster, "-bad"); err == nil {
|
||||
t.Fatal("expected invalid namespace to be rejected")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user