@@ -42,6 +42,9 @@ func (s *ConfigApplyTestSuite) SetupSuite() {
4242 s .teardownTest = utils .SetupConnectionTest (s .T (), false , false , false ,
4343 "../../config/agent/nginx-config-with-grpc-client.conf" )
4444 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 ())
4548}
4649
4750func (s * ConfigApplyTestSuite ) TearDownSuite () {
@@ -52,22 +55,18 @@ func (s *ConfigApplyTestSuite) TearDownTest() {
5255 utils .ClearManagementPlaneResponses (s .T (), utils .MockManagementPlaneAPIAddress )
5356}
5457
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 () {
6259 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 )
6461 s .T ().Logf ("Config apply responses: %v" , responses )
6562
6663 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 ())
6867}
6968
70- func (s * ConfigApplyTestSuite ) TestConfigApply_Test3_TestValidConfig () {
69+ func (s * ConfigApplyTestSuite ) TestConfigApply_Test2_TestValidConfig () {
7170 newConfigFile := "../../config/nginx/nginx-with-test-location.conf"
7271
7372 if os .Getenv ("IMAGE_PATH" ) == "/nginx-plus/agent" {
@@ -95,7 +94,7 @@ func (s *ConfigApplyTestSuite) TestConfigApply_Test3_TestValidConfig() {
9594 s .Equal ("Successfully updated all files" , responses [1 ].GetCommandResponse ().GetMessage ())
9695}
9796
98- func (s * ConfigApplyTestSuite ) TestConfigApply_Test4_TestInvalidConfig () {
97+ func (s * ConfigApplyTestSuite ) TestConfigApply_Test3_TestInvalidConfig () {
9998 err := utils .MockManagementPlaneGrpcContainer .CopyFileToContainer (
10099 s .ctx ,
101100 "../../config/nginx/invalid-nginx.conf" ,
@@ -117,7 +116,7 @@ func (s *ConfigApplyTestSuite) TestConfigApply_Test4_TestInvalidConfig() {
117116 s .Equal (configApplyErrorMessage , responses [1 ].GetCommandResponse ().GetError ())
118117}
119118
120- func (s * ConfigApplyTestSuite ) TestConfigApply_Test5_TestFileNotInAllowedDirectory () {
119+ func (s * ConfigApplyTestSuite ) TestConfigApply_Test4_TestFileNotInAllowedDirectory () {
121120 utils .PerformInvalidConfigApply (s .T (), s .nginxInstanceID )
122121
123122 responses := utils .ManagementPlaneResponses (s .T (), 1 , utils .MockManagementPlaneAPIAddress )
@@ -131,32 +130,23 @@ func (s *ConfigApplyTestSuite) TestConfigApply_Test5_TestFileNotInAllowedDirecto
131130 )
132131}
133132
134- func TestConfigApplyTestSuite (t * testing.T ) {
135- suite .Run (t , new (ConfigApplyTestSuite ))
136- }
137-
138133func (s * ConfigApplyChunkingTestSuite ) SetupSuite () {
139134 s .ctx = context .Background ()
140135 s .teardownTest = utils .SetupConnectionTest (s .T (), false , false , false ,
141136 "../../config/agent/nginx-config-with-max-file-size.conf" )
142137 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 ())
143141}
144142
145143func (s * ConfigApplyChunkingTestSuite ) TearDownSuite () {
146144 s .teardownTest (s .T ())
147145}
148146
149- func (s * ConfigApplyChunkingTestSuite ) TearDownTest () {
147+ func (s * ConfigApplyChunkingTestSuite ) TestConfigApplyChunking () {
150148 utils .ClearManagementPlaneResponses (s .T (), utils .MockManagementPlaneAPIAddress )
151- }
152149
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 () {
160150 newConfigFile := "../../config/nginx/nginx-1mb-file.conf"
161151
162152 err := utils .MockManagementPlaneGrpcContainer .CopyFileToContainer (
@@ -182,6 +172,7 @@ func (s *ConfigApplyChunkingTestSuite) TestConfigApplyChunking_Test2_TestChunked
182172 s .Equal ("Successfully updated all files" , responses [1 ].GetCommandResponse ().GetMessage ())
183173}
184174
185- func TestConfigApplyChunkingTestSuite (t * testing.T ) {
175+ func TestConfigApplyTestSuite (t * testing.T ) {
176+ suite .Run (t , new (ConfigApplyTestSuite ))
186177 suite .Run (t , new (ConfigApplyChunkingTestSuite ))
187178}
0 commit comments