-
Notifications
You must be signed in to change notification settings - Fork 1
/
appuio_cloud_persistent_storage.jsonnet
78 lines (71 loc) · 2.29 KB
/
appuio_cloud_persistent_storage.jsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
local c = import 'common.libsonnet';
local query = importstr '../appuio_cloud_persistent_storage.promql';
local commonLabels = {
cluster_id: 'c-appuio-cloudscale-lpg-2',
tenant_id: 'c-appuio-cloudscale-lpg-2',
};
// One pvc, minimal (=1 byte) request
// 10 samples
local baseSeries = {
testprojectNamespaceOrgLabel: c.series('kube_namespace_labels', commonLabels {
namespace: 'testproject',
label_appuio_io_organization: 'cherry-pickers-inc',
}, '1x10'),
local pvcID = 'pvc-da01b12d-2e31-44da-8312-f91169256221',
pvCapacity: c.series('kube_persistentvolume_capacity_bytes', commonLabels {
persistentvolume: pvcID,
}, '1x10'),
pvInfo: c.series('kube_persistentvolume_info', commonLabels {
persistentvolume: pvcID,
storageclass: 'ssd',
}, '1x10'),
pvcRef: c.series('kube_persistentvolume_claim_ref', commonLabels {
claim_namespace: 'testproject',
name: 'important-database',
persistentvolume: pvcID,
}, '1x10'),
};
local baseCalculatedLabels = {
category: 'c-appuio-cloudscale-lpg-2:testproject',
cluster_id: 'c-appuio-cloudscale-lpg-2',
namespace: 'testproject',
product: 'appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:cherry-pickers-inc:testproject:ssd',
storageclass: 'ssd',
tenant_id: 'cherry-pickers-inc',
};
{
tests: [
c.test('minimal PVC',
baseSeries,
query,
{
labels: c.formatLabels(baseCalculatedLabels),
value: 10,
}),
c.test('higher than 1GiB request',
baseSeries {
pvCapacity+: {
values: '%sx10' % (5 * 1024 * 1024 * 1024),
},
},
query,
{
labels: c.formatLabels(baseCalculatedLabels),
value: 5 * 10,
}),
c.test('unrelated kube_persistentvolume_info changes do not throw errors - there is an overlap since series go stale only after a few missed scrapes',
baseSeries {
pvInfoUpdated: self.pvInfo {
_labels+:: {
csi_volume_handle: '672004be-a86b-44e0-b446-1255a1f8b340',
},
values: '_x5 1x5',
},
},
query,
{
labels: c.formatLabels(baseCalculatedLabels),
value: 10,
}),
],
}