Skip to content

Commit 9e3c964

Browse files
committed
Fix merge conflicts
1 parent 916c7f1 commit 9e3c964

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

test/integration/managementplane/config_apply_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package managementplane
88
import (
99
"context"
1010
"fmt"
11+
"sort"
1112
"testing"
1213

1314
"github.com/nginx/agent/v3/test/integration/utils"
@@ -18,9 +19,8 @@ import (
1819
)
1920

2021
const (
21-
configApplyErrorMessage = "failed validating config NGINX config test failed exit status 1:" +
22-
" nginx: [emerg] unexpected end of file, expecting \";\" or \"}\" in /etc/nginx/nginx.conf:2\nnginx: " +
23-
"configuration file /etc/nginx/nginx.conf test failed\n"
22+
configApplyErrorMessage = "failed to parse config invalid " +
23+
"number of arguments in \"worker_processes\" directive in /etc/nginx/nginx.conf:1"
2424
)
2525

2626
func TestGrpc_ConfigApply(t *testing.T) {
@@ -46,21 +46,29 @@ func TestGrpc_ConfigApply(t *testing.T) {
4646

4747
t.Run("Test 2: Valid config", func(t *testing.T) {
4848
utils.ClearManagementPlaneResponses(t)
49+
newConfigFile := "../../config/nginx/nginx-with-test-location.conf"
50+
4951
err := utils.MockManagementPlaneGrpcContainer.CopyFileToContainer(
5052
ctx,
51-
"../../config/nginx/nginx-with-test-location.conf",
53+
newConfigFile,
5254
fmt.Sprintf("/mock-management-plane-grpc/config/%s/etc/nginx/nginx.conf", nginxInstanceID),
5355
0o666,
5456
)
5557
require.NoError(t, err)
5658

5759
utils.PerformConfigApply(t, nginxInstanceID)
5860

59-
responses = utils.GetManagementPlaneResponses(t, 1)
61+
responses = utils.GetManagementPlaneResponses(t, 2)
6062
t.Logf("Config apply responses: %v", responses)
6163

64+
sort.Slice(responses, func(i, j int) bool {
65+
return responses[i].GetCommandResponse().GetMessage() < responses[j].GetCommandResponse().GetMessage()
66+
})
67+
6268
assert.Equal(t, mpi.CommandResponse_COMMAND_STATUS_OK, responses[0].GetCommandResponse().GetStatus())
6369
assert.Equal(t, "Config apply successful", responses[0].GetCommandResponse().GetMessage())
70+
assert.Equal(t, mpi.CommandResponse_COMMAND_STATUS_OK, responses[1].GetCommandResponse().GetStatus())
71+
assert.Equal(t, "Successfully updated all files", responses[1].GetCommandResponse().GetMessage())
6472
})
6573

6674
t.Run("Test 3: Invalid config", func(t *testing.T) {

test/integration/utils/config_apply_utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import (
1717
)
1818

1919
const (
20-
RetryCount = 5
21-
RetryWaitTime = 4 * time.Second
22-
RetryMaxWaitTime = 5 * time.Second
20+
RetryCount = 8
21+
RetryWaitTime = 5 * time.Second
22+
RetryMaxWaitTime = 6 * time.Second
2323
)
2424

2525
var MockManagementPlaneAPIAddress string
@@ -41,6 +41,7 @@ func PerformInvalidConfigApply(t *testing.T, nginxInstanceID string) {
4141
t.Helper()
4242

4343
client := resty.New()
44+
4445
client.SetRetryCount(RetryCount).SetRetryWaitTime(RetryWaitTime).SetRetryMaxWaitTime(RetryMaxWaitTime)
4546

4647
body := fmt.Sprintf(`{

test/integration/utils/grpc_management_plane_utils.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,107 +336,151 @@ func VerifyUpdateDataPlaneHealth(t *testing.T) {
336336
t.Helper()
337337

338338
client := resty.New()
339+
339340
client.SetRetryCount(RetryCount).SetRetryWaitTime(RetryWaitTime).SetRetryMaxWaitTime(RetryMaxWaitTime)
341+
340342
client.AddRetryCondition(
343+
341344
func(r *resty.Response, err error) bool {
342345
return r.StatusCode() == http.StatusNotFound
343346
},
344347
)
345348

346349
url := fmt.Sprintf("http://%s/api/v1/health", MockManagementPlaneAPIAddress)
350+
347351
resp, err := client.R().EnableTrace().Get(url)
352+
348353
require.NoError(t, err)
354+
349355
assert.Equal(t, http.StatusOK, resp.StatusCode())
350356

351357
responseData := resp.Body()
358+
352359
t.Logf("Response: %s", string(responseData))
360+
353361
assert.True(t, json.Valid(responseData))
354362

355363
pb := protojson.UnmarshalOptions{DiscardUnknown: true}
356364

357365
updateDataPlaneHealthRequest := mpi.UpdateDataPlaneHealthRequest{}
366+
358367
unmarshalErr := pb.Unmarshal(responseData, &updateDataPlaneHealthRequest)
368+
359369
require.NoError(t, unmarshalErr)
360370

361371
t.Logf("UpdateDataPlaneHealthRequest: %v", &updateDataPlaneHealthRequest)
362372

363373
assert.NotNil(t, &updateDataPlaneHealthRequest)
364374

365375
// Verify message metadata
376+
366377
messageMeta := updateDataPlaneHealthRequest.GetMessageMeta()
378+
367379
assert.NotEmpty(t, messageMeta.GetCorrelationId())
380+
368381
assert.NotEmpty(t, messageMeta.GetMessageId())
382+
369383
assert.NotEmpty(t, messageMeta.GetTimestamp())
370384

371385
healths := updateDataPlaneHealthRequest.GetInstanceHealths()
386+
372387
assert.Len(t, healths, 1)
373388

374389
// Verify health metadata
390+
375391
assert.NotEmpty(t, healths[0].GetInstanceId())
392+
376393
assert.Equal(t, mpi.InstanceHealth_INSTANCE_HEALTH_STATUS_HEALTHY, healths[0].GetInstanceHealthStatus())
377394
}
378395

379396
func VerifyUpdateDataPlaneStatus(t *testing.T) {
380397
t.Helper()
381398

382399
client := resty.New()
400+
383401
client.SetRetryCount(statusRetryCount).SetRetryWaitTime(retryWait).SetRetryMaxWaitTime(retryMaxWait)
384402

385403
url := fmt.Sprintf("http://%s/api/v1/status", MockManagementPlaneAPIAddress)
404+
386405
resp, err := client.R().EnableTrace().Get(url)
387406

388407
require.NoError(t, err)
408+
389409
assert.Equal(t, http.StatusOK, resp.StatusCode())
390410

391411
updateDataPlaneStatusRequest := mpi.UpdateDataPlaneStatusRequest{}
392412

393413
responseData := resp.Body()
414+
394415
t.Logf("Response: %s", string(responseData))
416+
395417
assert.True(t, json.Valid(responseData))
396418

397419
pb := protojson.UnmarshalOptions{DiscardUnknown: true}
420+
398421
unmarshalErr := pb.Unmarshal(responseData, &updateDataPlaneStatusRequest)
422+
399423
require.NoError(t, unmarshalErr)
400424

401425
t.Logf("UpdateDataPlaneStatusRequest: %v", &updateDataPlaneStatusRequest)
402426

403427
assert.NotNil(t, &updateDataPlaneStatusRequest)
404428

405429
// Verify message metadata
430+
406431
messageMeta := updateDataPlaneStatusRequest.GetMessageMeta()
432+
407433
assert.NotEmpty(t, messageMeta.GetCorrelationId())
434+
408435
assert.NotEmpty(t, messageMeta.GetMessageId())
436+
409437
assert.NotEmpty(t, messageMeta.GetTimestamp())
410438

411439
instances := updateDataPlaneStatusRequest.GetResource().GetInstances()
440+
412441
sort.Slice(instances, func(i, j int) bool {
413442
return instances[i].GetInstanceMeta().GetInstanceType() < instances[j].GetInstanceMeta().GetInstanceType()
414443
})
444+
415445
assert.Len(t, instances, instanceLen)
416446

417447
// Verify agent instance metadata
448+
418449
assert.NotEmpty(t, instances[0].GetInstanceMeta().GetInstanceId())
450+
419451
assert.Equal(t, mpi.InstanceMeta_INSTANCE_TYPE_AGENT, instances[0].GetInstanceMeta().GetInstanceType())
452+
420453
assert.NotEmpty(t, instances[0].GetInstanceMeta().GetVersion())
421454

422455
// Verify agent instance configuration
456+
423457
assert.Empty(t, instances[0].GetInstanceConfig().GetActions())
458+
424459
assert.NotEmpty(t, instances[0].GetInstanceRuntime().GetProcessId())
460+
425461
assert.Equal(t, "/usr/bin/nginx-agent", instances[0].GetInstanceRuntime().GetBinaryPath())
462+
426463
assert.Equal(t, "/etc/nginx-agent/nginx-agent.conf", instances[0].GetInstanceRuntime().GetConfigPath())
427464

428465
// Verify NGINX instance metadata
466+
429467
assert.NotEmpty(t, instances[1].GetInstanceMeta().GetInstanceId())
468+
430469
if os.Getenv("IMAGE_PATH") == "/nginx-plus/agent" {
431470
assert.Equal(t, mpi.InstanceMeta_INSTANCE_TYPE_NGINX_PLUS, instances[1].GetInstanceMeta().GetInstanceType())
432471
} else {
433472
assert.Equal(t, mpi.InstanceMeta_INSTANCE_TYPE_NGINX, instances[1].GetInstanceMeta().GetInstanceType())
434473
}
474+
435475
assert.NotEmpty(t, instances[1].GetInstanceMeta().GetVersion())
436476

437477
// Verify NGINX instance configuration
478+
438479
assert.Empty(t, instances[1].GetInstanceConfig().GetActions())
480+
439481
assert.NotEmpty(t, instances[1].GetInstanceRuntime().GetProcessId())
482+
440483
assert.Equal(t, "/usr/sbin/nginx", instances[1].GetInstanceRuntime().GetBinaryPath())
484+
441485
assert.Equal(t, "/etc/nginx/nginx.conf", instances[1].GetInstanceRuntime().GetConfigPath())
442486
}

0 commit comments

Comments
 (0)