9
9
"context"
10
10
"testing"
11
11
12
+ pkg "github.com/nginx/agent/v3/pkg/config"
13
+
12
14
"github.com/nginx/agent/v3/internal/collector"
13
15
"github.com/nginx/agent/v3/internal/command"
14
16
"github.com/nginx/agent/v3/internal/file"
@@ -35,7 +37,8 @@ func TestLoadPlugins(t *testing.T) {
35
37
& resource.Resource {},
36
38
& watcher.Watcher {},
37
39
},
38
- }, {
40
+ },
41
+ {
39
42
name : "Test 2: Load file and command plugins" ,
40
43
input : & config.Config {
41
44
Command : & config.Command {
@@ -53,21 +56,82 @@ func TestLoadPlugins(t *testing.T) {
53
56
& file.FilePlugin {},
54
57
& watcher.Watcher {},
55
58
},
56
- }, {
59
+ },
60
+ {
57
61
name : "Test 3: Load metrics collector plugin" ,
58
62
input : & config.Config {
59
63
Collector : & config.Collector {
60
64
Exporters : config.Exporters {
61
65
Debug : & config.DebugExporter {},
62
66
},
63
67
},
68
+ Features : config .DefaultFeatures (),
64
69
},
65
70
expected : []bus.Plugin {
66
71
& resource.Resource {},
67
72
& collector.Collector {},
68
73
& watcher.Watcher {},
69
74
},
70
75
},
76
+ {
77
+ name : "Test 4: Metrics collector plugin, feature disabled" ,
78
+ input : & config.Config {
79
+ Command : & config.Command {
80
+ Server : & config.ServerConfig {
81
+ Host : "127.0.0.1" ,
82
+ Port : 443 ,
83
+ Type : config .Grpc ,
84
+ },
85
+ },
86
+ Collector : & config.Collector {
87
+ Exporters : config.Exporters {
88
+ Debug : & config.DebugExporter {},
89
+ },
90
+ },
91
+ Features : []string {
92
+ pkg .FeatureConfiguration ,
93
+ pkg .FeatureFileWatcher ,
94
+ },
95
+ },
96
+ expected : []bus.Plugin {
97
+ & resource.Resource {},
98
+ & command.CommandPlugin {},
99
+ & file.FilePlugin {},
100
+ & watcher.Watcher {},
101
+ },
102
+ },
103
+ {
104
+ name : "Test 5: All features enabled" ,
105
+ input : & config.Config {
106
+ Command : & config.Command {
107
+ Server : & config.ServerConfig {
108
+ Host : "127.0.0.1" ,
109
+ Port : 443 ,
110
+ Type : config .Grpc ,
111
+ },
112
+ },
113
+ Collector : & config.Collector {
114
+ Exporters : config.Exporters {
115
+ Debug : & config.DebugExporter {},
116
+ },
117
+ },
118
+ Features : []string {
119
+ pkg .FeatureConfiguration ,
120
+ pkg .FeatureMetrics ,
121
+ pkg .FeatureFileWatcher ,
122
+ pkg .FeatureCertificates ,
123
+ pkg .FeatureAPIAction ,
124
+ pkg .FeatureLogsNap ,
125
+ },
126
+ },
127
+ expected : []bus.Plugin {
128
+ & resource.Resource {},
129
+ & command.CommandPlugin {},
130
+ & file.FilePlugin {},
131
+ & collector.Collector {},
132
+ & watcher.Watcher {},
133
+ },
134
+ },
71
135
}
72
136
73
137
for _ , test := range tests {
0 commit comments