@@ -42,6 +42,9 @@ func (s *ConfigApplyTestSuite) SetupSuite() {
42
42
s .teardownTest = utils .SetupConnectionTest (s .T (), false , false , false ,
43
43
"../../config/agent/nginx-config-with-grpc-client.conf" )
44
44
s .nginxInstanceID = utils .VerifyConnection (s .T (), 2 , utils .MockManagementPlaneAPIAddress )
45
+ responses := utils .ManagementPlaneResponses (s .T (), 1 , utils .MockManagementPlaneAPIAddress )
46
+ s .Require ().Equal (mpi .CommandResponse_COMMAND_STATUS_OK , responses [0 ].GetCommandResponse ().GetStatus ())
47
+ s .Require ().Equal ("Successfully updated all files" , responses [0 ].GetCommandResponse ().GetMessage ())
45
48
}
46
49
47
50
func (s * ConfigApplyTestSuite ) TearDownSuite () {
@@ -52,22 +55,18 @@ func (s *ConfigApplyTestSuite) TearDownTest() {
52
55
utils .ClearManagementPlaneResponses (s .T (), utils .MockManagementPlaneAPIAddress )
53
56
}
54
57
55
- func (s * ConfigApplyTestSuite ) TestConfigApply_Test1_TestSetup () {
56
- responses := utils .ManagementPlaneResponses (s .T (), 1 , utils .MockManagementPlaneAPIAddress )
57
- s .Require ().Equal (mpi .CommandResponse_COMMAND_STATUS_OK , responses [0 ].GetCommandResponse ().GetStatus ())
58
- s .Require ().Equal ("Successfully updated all files" , responses [0 ].GetCommandResponse ().GetMessage ())
59
- }
60
-
61
- func (s * ConfigApplyTestSuite ) TestConfigApply_Test2_TestNoConfigChanges () {
58
+ func (s * ConfigApplyTestSuite ) TestConfigApply_Test1_TestNoConfigChanges () {
62
59
utils .PerformConfigApply (s .T (), s .nginxInstanceID , utils .MockManagementPlaneAPIAddress )
63
- responses := utils .ManagementPlaneResponses (s .T (), 1 , utils .MockManagementPlaneAPIAddress )
60
+ responses := utils .ManagementPlaneResponses (s .T (), 2 , utils .MockManagementPlaneAPIAddress )
64
61
s .T ().Logf ("Config apply responses: %v" , responses )
65
62
66
63
s .Equal (mpi .CommandResponse_COMMAND_STATUS_OK , responses [0 ].GetCommandResponse ().GetStatus ())
67
- s .Equal ("Config apply successful, no files to change" , responses [0 ].GetCommandResponse ().GetMessage ())
64
+ s .Equal ("Successfully updated all files" , responses [0 ].GetCommandResponse ().GetMessage ())
65
+ s .Equal (mpi .CommandResponse_COMMAND_STATUS_OK , responses [1 ].GetCommandResponse ().GetStatus ())
66
+ s .Equal ("Config apply successful, no files to change" , responses [1 ].GetCommandResponse ().GetMessage ())
68
67
}
69
68
70
- func (s * ConfigApplyTestSuite ) TestConfigApply_Test3_TestValidConfig () {
69
+ func (s * ConfigApplyTestSuite ) TestConfigApply_Test2_TestValidConfig () {
71
70
newConfigFile := "../../config/nginx/nginx-with-test-location.conf"
72
71
73
72
if os .Getenv ("IMAGE_PATH" ) == "/nginx-plus/agent" {
@@ -95,7 +94,7 @@ func (s *ConfigApplyTestSuite) TestConfigApply_Test3_TestValidConfig() {
95
94
s .Equal ("Successfully updated all files" , responses [1 ].GetCommandResponse ().GetMessage ())
96
95
}
97
96
98
- func (s * ConfigApplyTestSuite ) TestConfigApply_Test4_TestInvalidConfig () {
97
+ func (s * ConfigApplyTestSuite ) TestConfigApply_Test3_TestInvalidConfig () {
99
98
err := utils .MockManagementPlaneGrpcContainer .CopyFileToContainer (
100
99
s .ctx ,
101
100
"../../config/nginx/invalid-nginx.conf" ,
@@ -117,7 +116,7 @@ func (s *ConfigApplyTestSuite) TestConfigApply_Test4_TestInvalidConfig() {
117
116
s .Equal (configApplyErrorMessage , responses [1 ].GetCommandResponse ().GetError ())
118
117
}
119
118
120
- func (s * ConfigApplyTestSuite ) TestConfigApply_Test5_TestFileNotInAllowedDirectory () {
119
+ func (s * ConfigApplyTestSuite ) TestConfigApply_Test4_TestFileNotInAllowedDirectory () {
121
120
utils .PerformInvalidConfigApply (s .T (), s .nginxInstanceID )
122
121
123
122
responses := utils .ManagementPlaneResponses (s .T (), 1 , utils .MockManagementPlaneAPIAddress )
@@ -131,32 +130,23 @@ func (s *ConfigApplyTestSuite) TestConfigApply_Test5_TestFileNotInAllowedDirecto
131
130
)
132
131
}
133
132
134
- func TestConfigApplyTestSuite (t * testing.T ) {
135
- suite .Run (t , new (ConfigApplyTestSuite ))
136
- }
137
-
138
133
func (s * ConfigApplyChunkingTestSuite ) SetupSuite () {
139
134
s .ctx = context .Background ()
140
135
s .teardownTest = utils .SetupConnectionTest (s .T (), false , false , false ,
141
136
"../../config/agent/nginx-config-with-max-file-size.conf" )
142
137
s .nginxInstanceID = utils .VerifyConnection (s .T (), 2 , utils .MockManagementPlaneAPIAddress )
138
+ responses := utils .ManagementPlaneResponses (s .T (), 1 , utils .MockManagementPlaneAPIAddress )
139
+ s .Require ().Equal (mpi .CommandResponse_COMMAND_STATUS_OK , responses [0 ].GetCommandResponse ().GetStatus ())
140
+ s .Require ().Equal ("Successfully updated all files" , responses [0 ].GetCommandResponse ().GetMessage ())
143
141
}
144
142
145
143
func (s * ConfigApplyChunkingTestSuite ) TearDownSuite () {
146
144
s .teardownTest (s .T ())
147
145
}
148
146
149
- func (s * ConfigApplyChunkingTestSuite ) TearDownTest () {
147
+ func (s * ConfigApplyChunkingTestSuite ) TestConfigApplyChunking () {
150
148
utils .ClearManagementPlaneResponses (s .T (), utils .MockManagementPlaneAPIAddress )
151
- }
152
149
153
- func (s * ConfigApplyChunkingTestSuite ) TestConfigApplyChunking_Test1_TestSetup () {
154
- responses := utils .ManagementPlaneResponses (s .T (), 1 , utils .MockManagementPlaneAPIAddress )
155
- s .Require ().Equal (mpi .CommandResponse_COMMAND_STATUS_OK , responses [0 ].GetCommandResponse ().GetStatus ())
156
- s .Require ().Equal ("Successfully updated all files" , responses [0 ].GetCommandResponse ().GetMessage ())
157
- }
158
-
159
- func (s * ConfigApplyChunkingTestSuite ) TestConfigApplyChunking_Test2_TestChunkedConfigApply () {
160
150
newConfigFile := "../../config/nginx/nginx-1mb-file.conf"
161
151
162
152
err := utils .MockManagementPlaneGrpcContainer .CopyFileToContainer (
@@ -182,6 +172,7 @@ func (s *ConfigApplyChunkingTestSuite) TestConfigApplyChunking_Test2_TestChunked
182
172
s .Equal ("Successfully updated all files" , responses [1 ].GetCommandResponse ().GetMessage ())
183
173
}
184
174
185
- func TestConfigApplyChunkingTestSuite (t * testing.T ) {
175
+ func TestConfigApplyTestSuite (t * testing.T ) {
176
+ suite .Run (t , new (ConfigApplyTestSuite ))
186
177
suite .Run (t , new (ConfigApplyChunkingTestSuite ))
187
178
}
0 commit comments