generated from konveyor/template-repo
/
application_metrics.go
54 lines (45 loc) · 1.25 KB
/
application_metrics.go
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
package metrics
import (
"os"
"strconv"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/konveyor/go-konveyor-tests/utils"
"github.com/konveyor/tackle2-hub/api"
)
var (
metricValue int
metricName string = "konveyor_applications_inventoried"
apps []api.Application
Application = utils.Application
)
var _ = Describe("Application Metrics", Ordered, func() {
BeforeAll(func() {
// Get the current metric value
metricValue = GetMetricValue(metricName)
})
AfterAll(func() {
// Resources cleanup
if keep, _ := strconv.ParseBool(os.Getenv("KEEP")); keep {
return
}
utils.DeleteApplicationsBySlice(apps)
})
Context("Create applications", func() {
It("Should increase the applications gauge", func() {
numOfApps := 3
apps = utils.CreateMultipleApplications(numOfApps)
metricValue += len(apps)
Expect(GetMetricValue(metricName)).To(Equal(metricValue))
})
})
Context("Delete application", func() {
It("Should decrease the applications gauge", func() {
// Delete the last application item
lastApplicationItem := apps[len(apps)-1]
utils.DeleteApplicationsBySlice([]api.Application{lastApplicationItem})
metricValue--
Expect(GetMetricValue(metricName)).To(Equal(metricValue))
})
})
})