Skip to content

Commit

Permalink
Tests and query unification
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan committed Mar 8, 2023
1 parent 95538fa commit 3f06bc1
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 56 deletions.
19 changes: 5 additions & 14 deletions pkg/db/seeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ var appuioCloudLoadbalancerQuery string
//go:embed seeds/appuio_cloud_persistent_storage.promql
var appuioCloudPersistentStorageQuery string

//go:embed seeds/appuio_managed_openshift_vcpu_app.promql
var appuioManagedOpenShiftvCPUAppQuery string

//go:embed seeds/appuio_managed_openshift_vcpu_storage.promql
var appuioManagedOpenShiftvCPUStorageQuery string
//go:embed seeds/appuio_managed_openshift_vcpu.promql
var appuioManagedOpenShiftvCPUQuery string

//go:embed seeds/appcat_postgresql_vshn_standalone.promql
var appcatPostgresqlVSHNStandalone string
Expand Down Expand Up @@ -67,15 +64,9 @@ var DefaultQueries = []Query{
Unit: "GiB",
},
{
Name: "appuio_managed_openshift_vcpu_app",
Description: "vCPU aggregated by cluster and service level for app nodes",
Query: appuioManagedOpenShiftvCPUAppQuery,
Unit: "vCPU",
},
{
Name: "appuio_managed_openshift_vcpu_app",
Description: "vCPU aggregated by cluster and service level for storage nodes",
Query: appuioManagedOpenShiftvCPUStorageQuery,
Name: "appuio_managed_openshift_vcpu",
Description: "vCPU aggregated by cluster, node (app, storage), and service level",
Query: appuioManagedOpenShiftvCPUQuery,
Unit: "vCPU",
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ max_over_time(
label_replace(
# Add the base product identifier.
label_replace(
sum by(cluster_id, vshn_service_level, tenant_id) (
sum by(cluster_id, vshn_service_level, tenant_id, role) (
sum by (tenant_id, cluster_id, instance, vshn_service_level) (
min without(prometheus_replica) (node_cpu_info)
) * on (tenant_id, cluster_id, instance, vshn_service_level)
) * on (tenant_id, cluster_id, instance, vshn_service_level) group_left(role)
label_join(
(group without(prometheus_replica) (kube_node_role{role="app"})), "instance", "", "node")
(group without(prometheus_replica) (kube_node_role{role=~"app|storage"})),
"instance",
"",
"node"
)
),
"product",
"appuio_managed_openshift_vcpu_app",
"product",
".*"
"appuio_managed_openshift_vcpu_$1",
"role",
"(.*)"
),
"class",
"$1",
Expand Down
36 changes: 0 additions & 36 deletions pkg/db/seeds/appuio_managed_openshift_vcpu_storage.promql

This file was deleted.

64 changes: 64 additions & 0 deletions pkg/db/seeds/promtest/appuio_managed_openshift_vcpu.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
local c = import 'common.libsonnet';

local query = importstr '../appuio_managed_openshift_vcpu.promql';

local commonLabels = {
cluster_id: 'c-managed-openshift',
tenant_id: 't-managed-openshift',
vshn_service_level: 'ondemand',
};

local baseSeries = {
appNodeRoleLabel: c.series('kube_node_role', commonLabels {
node: 'app-test',
role: 'app',
}, '1x120'),

appNodeCPUInfoLabel0: c.series('node_cpu_info', commonLabels {
instance: 'app-test',
core: '0',
}, '1x120'),
appNodeCPUInfoLabel1: c.series('node_cpu_info', commonLabels {
instance: 'app-test',
core: '1',
}, '1x120'),

storageNodeRoleLabel: c.series('kube_node_role', commonLabels {
node: 'storage-test',
role: 'storage',
}, '1x120'),

storageNodeCPUInfoLabel0: c.series('node_cpu_info', commonLabels {
instance: 'storage-test',
core: '0',
}, '1x120'),
};

{
tests: [
c.test(
'two app CPUs and one storage CPU',
baseSeries,
query,
[
{
labels: c.formatLabels(commonLabels {
class: super.vshn_service_level,
role: 'app',
product: 'appuio_managed_openshift_vcpu_app:c-managed-openshift:t-managed-openshift::ondemand',
}),
value: 2,
},
{
labels: c.formatLabels(commonLabels {
class: super.vshn_service_level,
role: 'storage',
product: 'appuio_managed_openshift_vcpu_storage:c-managed-openshift:t-managed-openshift::ondemand',
}),
value: 1,
},
]
),

],
}

0 comments on commit 3f06bc1

Please sign in to comment.