-
Notifications
You must be signed in to change notification settings - Fork 1
/
appuio_cloud_loadbalancer.jsonnet
85 lines (77 loc) · 2.87 KB
/
appuio_cloud_loadbalancer.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
79
80
81
82
83
84
85
local c = import 'common.libsonnet';
local query = importstr '../appuio_cloud_loadbalancer.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'),
pvCapacity: c.series('kube_service_spec_type', commonLabels {
type: 'LoadBalancer',
namespace: 'testproject',
}, '1x10'),
};
local baseCalculatedLabels = {
category: 'c-appuio-cloudscale-lpg-2:testproject',
cluster_id: 'c-appuio-cloudscale-lpg-2',
namespace: 'testproject',
product: 'appuio_cloud_loadbalancer:c-appuio-cloudscale-lpg-2:cherry-pickers-inc:testproject',
tenant_id: 'cherry-pickers-inc',
};
{
tests: [
c.test('minimal PVC',
baseSeries,
query,
{
labels: c.formatLabels(baseCalculatedLabels),
value: 10,
}),
c.test('unrelated kube_namespace_labels changes do not throw errors - there is an overlap since series go stale only after a few missed scrapes',
baseSeries {
testprojectNamespaceOrgLabelUpdated: self.testprojectNamespaceOrgLabel {
_labels+:: {
custom_appuio_io_myid: '672004be-a86b-44e0-b446-1255a1f8b340',
},
values: '_x5 1x5',
},
},
query,
{
labels: c.formatLabels(baseCalculatedLabels),
value: 10,
}),
c.test('organization changes do not throw many-to-many errors - there is an overlap since series go stale only after a few missed scrapes',
baseSeries {
testprojectNamespaceOrgLabelUpdated: self.testprojectNamespaceOrgLabel {
_labels+:: {
label_appuio_io_organization: 'carrot-pickers-inc',
},
// We cheat here and use an impossible value.
// Since we use min() and bottomk() in the query this priotizes this series less than the other.
// It's ugly but it prevents flaky tests since otherwise one of the series gets picked randomly.
values: '_x2 2x8',
},
},
query,
[
{
labels: c.formatLabels(baseCalculatedLabels),
value: 8,
},
{
labels: c.formatLabels(baseCalculatedLabels {
tenant_id: 'carrot-pickers-inc',
product: 'appuio_cloud_loadbalancer:c-appuio-cloudscale-lpg-2:carrot-pickers-inc:testproject',
}),
// 1 service * two samples * 2 because of the cheat above.
value: 1 * 2 * 2,
},
]),
],
}