Skip to content

Commit 5e5a3c5

Browse files
committed
Fix failing unit tests
1 parent b7d7dd9 commit 5e5a3c5

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

internal/controller/telemetry/collector.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,17 @@ type ConfigurationGetter interface {
4141
//
4242
//go:generate go run -tags generator github.com/nginx/telemetry-exporter/cmd/generator -type=Data -scheme -scheme-protocol=NGFProductTelemetry -scheme-df-datatype=ngf-product-telemetry
4343
type Data struct {
44-
// ImageSource tells whether the image was built by GitHub or locally (values are 'gha', 'local', or 'unknown')
4544
ImageSource string
46-
tel.Data // embedding is required by the generator.
47-
// FlagNames contains the command-line flag names.
48-
FlagNames []string
49-
// FlagValues contains the values of the command-line flags, where each value corresponds to the flag from FlagNames
50-
// at the same index.
51-
// Each value is either 'true' or 'false' for boolean flags and 'default' or 'user-defined' for non-boolean flags.
52-
FlagValues []string
53-
// SnippetsFiltersDirectives contains the directive-context strings of all applied SnippetsFilters.
54-
// Both lists are ordered first by count, then by lexicographical order of the context string,
55-
// then lastly by directive string.
56-
SnippetsFiltersDirectives []string
57-
// SnippetsFiltersDirectivesCount contains the count of the directive-context strings, where each count
58-
// corresponds to the string from SnippetsFiltersDirectives at the same index.
59-
// Both lists are ordered first by count, then by lexicographical order of the context string,
60-
// then lastly by directive string.
45+
BuildOS string
46+
tel.Data
47+
FlagNames []string
48+
FlagValues []string
49+
SnippetsFiltersDirectives []string
6150
SnippetsFiltersDirectivesCount []int64
62-
NGFResourceCounts // embedding is required by the generator.
63-
// NginxPodCount is the total number of Nginx data plane Pods.
64-
NginxPodCount int64
65-
// ControlPlanePodCount is the total number of NGF control plane Pods.
66-
ControlPlanePodCount int64
67-
// NginxOneConnectionEnabled is a boolean that indicates whether the connection to the Nginx One Console is enabled.
51+
NGFResourceCounts
52+
NginxPodCount int64
53+
ControlPlanePodCount int64
6854
NginxOneConnectionEnabled bool
69-
// BuildOS is the OS the NGF and NGINX binary was built on.
70-
BuildOS string
7155
}
7256

7357
// NGFResourceCounts stores the counts of all relevant resources that NGF processes and generates configuration from.

internal/controller/telemetry/collector_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ var _ = Describe("Collector", Ordered, func() {
172172
NGFResourceCounts: telemetry.NGFResourceCounts{},
173173
ControlPlanePodCount: 1,
174174
ImageSource: "local",
175+
BuildOS: "ubi",
175176
FlagNames: flags.Names,
176177
FlagValues: flags.Values,
177178
SnippetsFiltersDirectives: []string{},
@@ -193,9 +194,9 @@ var _ = Describe("Collector", Ordered, func() {
193194
Version: version,
194195
PodNSName: podNSName,
195196
ImageSource: "local",
197+
BuildOS: "ubi",
196198
Flags: flags,
197199
NginxOneConsoleConnection: true,
198-
BuildOS: "",
199200
})
200201

201202
baseGetCalls = createGetCallsFunc(ngfPod, ngfReplicaSet, kubeNamespace)

internal/controller/telemetry/data_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func TestDataAttributes(t *testing.T) {
8686
attribute.Int64("NginxPodCount", 3),
8787
attribute.Int64("ControlPlanePodCount", 3),
8888
attribute.Bool("NginxOneConnectionEnabled", true),
89+
attribute.String("BuildOS", ""),
8990
}
9091

9192
result := data.Attributes()
@@ -132,6 +133,7 @@ func TestDataAttributesWithEmptyData(t *testing.T) {
132133
attribute.Int64("NginxPodCount", 0),
133134
attribute.Int64("ControlPlanePodCount", 0),
134135
attribute.Bool("NginxOneConnectionEnabled", false),
136+
attribute.String("BuildOS", ""),
135137
}
136138

137139
result := data.Attributes()

0 commit comments

Comments
 (0)