Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/grpc/mpi/v1/command_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/grpc/mpi/v1/files_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.43.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.43.0
golang.org/x/crypto v0.51.0 // indirect
golang.org/x/net v0.54.0 // indirect
golang.org/x/sys v0.44.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
google.golang.org/grpc v1.80.0
)
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ github.com/foxboron/go-tpm-keyfiles v0.0.0-20251226215517-609e4778396f/go.mod h1
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ=
Expand Down Expand Up @@ -1083,8 +1081,6 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4=
golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand All @@ -1104,8 +1100,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.54.0 h1:2zJIZAxAHV/OHCDTCOHAYehQzLfSXuf/5SoL/Dv6w/w=
golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ=
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
Expand Down Expand Up @@ -1150,8 +1146,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/telemetry v0.0.0-20260409153401-be6f6cb8b1fa h1:efT73AJZfAAUV7SOip6pWGkwJDzIGiKBZGVzHYa+ve4=
golang.org/x/telemetry v0.0.0-20260409153401-be6f6cb8b1fa/go.mod h1:kHjTxDEnAu6/Nl9lDkzjWpR+bmKfxeiRuSDlsMb70gE=
Expand Down
108 changes: 86 additions & 22 deletions test/helpers/test_containers_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package helpers

import (
"bytes"
"context"
"io"
"os"
Expand All @@ -21,11 +22,17 @@ import (
const configFilePermissions = 0o600

type Parameters struct {
NginxConfigPath string
NginxAgentConfigPath string
LogMessage string
NginxConfigPath string
NginxAgentConfigPath string
NginxAgentOTELConfigPath string
LogMessage string
}

type ConfigFileDescriptor struct {
ContainerPath string
ExpectedPath string
LogLabel string
Comment thread
craigell marked this conversation as resolved.
}
type MockCollectorContainers struct {
Agent testcontainers.Container
Otel testcontainers.Container
Expand Down Expand Up @@ -58,7 +65,30 @@ func StartContainer(
"NGINX_LICENSE_JWT": nginxLicenseJwt,
}
}

files := []testcontainers.ContainerFile{
{
HostFilePath: parameters.NginxAgentConfigPath,
ContainerFilePath: "/etc/nginx-agent/nginx-agent.conf",
FileMode: configFilePermissions,
},
{
HostFilePath: parameters.NginxConfigPath,
ContainerFilePath: "/etc/nginx/nginx.conf",
FileMode: configFilePermissions,
},
{
HostFilePath: "../../config/nginx/mime.types",
ContainerFilePath: "/etc/nginx/mime.types",
FileMode: configFilePermissions,
},
}
if parameters.NginxAgentOTELConfigPath != "" {
files = append(files, testcontainers.ContainerFile{
HostFilePath: parameters.NginxAgentOTELConfigPath,
ContainerFilePath: "/etc/nginx-agent/my_config.yaml",
FileMode: configFilePermissions,
})
}
req := testcontainers.ContainerRequest{
FromDockerfile: testcontainers.FromDockerfile{
Context: "../../../",
Expand Down Expand Up @@ -90,24 +120,8 @@ func StartContainer(
"agent",
},
},
Files: []testcontainers.ContainerFile{
{
HostFilePath: parameters.NginxAgentConfigPath,
ContainerFilePath: "/etc/nginx-agent/nginx-agent.conf",
FileMode: configFilePermissions,
},
{
HostFilePath: parameters.NginxConfigPath,
ContainerFilePath: "/etc/nginx/nginx.conf",
FileMode: configFilePermissions,
},
{
HostFilePath: "../../config/nginx/mime.types",
ContainerFilePath: "/etc/nginx/mime.types",
FileMode: configFilePermissions,
},
},
Env: env,
Files: files,
Env: env,
}

container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
Expand Down Expand Up @@ -473,3 +487,53 @@ func LogAndTerminateStack(ctx context.Context, tb testing.TB,
logAndTerminate("Otel Collector", containers.Otel)
logAndTerminate("Prometheus", containers.Prometheus)
}

// ExtractFileFromContainer copies a file from the container at the given path and returns its contents as a string.
func ExtractFileFromContainer(
ctx context.Context,
tb testing.TB,
testContainer testcontainers.Container,
containerPath string,
) string {
tb.Helper()
fileContent, err := testContainer.CopyFileFromContainer(ctx, containerPath)
require.NoError(tb, err)

content, err := io.ReadAll(fileContent)
require.NoError(tb, err)
content = bytes.TrimSpace(content)

return string(content)
}

// ValidateContainerFiles compares files in the container to expected files on disk.
func ValidateContainerFiles(
ctx context.Context,
tb testing.TB,
testContainer testcontainers.Container,
files []ConfigFileDescriptor,
) {
tb.Helper()

for _, file := range files {
config := ExtractFileFromContainer(ctx, tb, testContainer, file.ContainerPath)
expectedConfig, err := os.ReadFile(file.ExpectedPath)
require.NoError(tb, err)

expectedConfig = bytes.TrimSpace(expectedConfig)
assert.Equal(tb, string(expectedConfig), config, "Mismatch in file: %s", file.LogLabel)
}
}

// AssertStringInContainerFile asserts that a string exists in a file inside the container.
func AssertStringInContainerFile(
ctx context.Context,
tb testing.TB,
testContainer testcontainers.Container,
containerPath string,
searchString string,
) {
tb.Helper()
content := ExtractFileFromContainer(ctx, tb, testContainer, containerPath)
assert.Contains(tb, content, searchString, "Expected phrase not found in file: %s", containerPath)
}
Empty file.
Comment thread
aphralG marked this conversation as resolved.
File renamed without changes.
52 changes: 52 additions & 0 deletions test/integration/upgrade/configs/default/otel-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
receivers:
containermetrics:
collection_interval: 1m0s
hostmetrics:
collection_interval: 1m0s
initial_delay: 1s
scrapers:
network:

processors:
batch/default_logs:
send_batch_size: 100
timeout: 1m0s
send_batch_max_size: 100
batch/default_metrics:
send_batch_size: 1000
timeout: 30s
send_batch_max_size: 1000
securityviolationsfilter/default: {}

exporters:
otlp_grpc/default:
endpoint: "managementPlane:9092"
timeout: 10s
retry_on_failure:
enabled: true
initial_interval: 10s
max_interval: 60s
max_elapsed_time: 10m
tls:
insecure: true
extensions:

service:
telemetry:
metrics:
level: none
logs:
level: DEBUG
output_paths: ["/var/log/nginx-agent/opentelemetry-collector-agent.log"]
error_output_paths: ["/var/log/nginx-agent/opentelemetry-collector-agent.log"]
extensions:

pipelines:
metrics/default:
receivers:
- containermetrics
- hostmetrics
processors:
- batch/default_metrics
exporters:
- otlp_grpc/default
52 changes: 52 additions & 0 deletions test/integration/upgrade/configs/expected-otel-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
receivers:
containermetrics:
collection_interval: 1m0s
hostmetrics:
collection_interval: 1m0s
initial_delay: 1s
scrapers:
network:

processors:
batch/default_logs:
send_batch_size: 100
timeout: 1m0s
send_batch_max_size: 100
batch/default_metrics:
send_batch_size: 1000
timeout: 30s
send_batch_max_size: 1000
securityviolationsfilter/default: {}

exporters:
otlp_grpc/default:
endpoint: "managementPlane:9092"
timeout: 10s
retry_on_failure:
enabled: true
initial_interval: 10s
max_interval: 60s
max_elapsed_time: 10m
tls:
insecure: true
extensions:

service:
telemetry:
metrics:
level: none
logs:
level: DEBUG
output_paths: ["/var/log/nginx-agent/opentelemetry-collector-agent.log"]
error_output_paths: ["/var/log/nginx-agent/opentelemetry-collector-agent.log"]
extensions:

pipelines:
metrics/default:
receivers:
- containermetrics
- hostmetrics
processors:
- batch/default_metrics
exporters:
- otlp_grpc/default
15 changes: 15 additions & 0 deletions test/integration/upgrade/configs/otel/my_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
receivers:
hostmetrics:
collection_interval: 10s
scrapers:
cpu:

exporters:
debug:
verbosity: detailed

service:
pipelines:
metrics:
receivers: [hostmetrics]
exporters: [debug]
28 changes: 28 additions & 0 deletions test/integration/upgrade/configs/otel/nginx-agent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# /etc/nginx-agent/nginx-agent.conf
#
# Configuration file for NGINX Agent.
#

log:
# set log level (error, warn, info, debug; default "info")
level: debug
# set log path. if empty, don't log to file.
path: /var/log/nginx-agent/

allowed_directories:
- /etc/nginx
- /usr/local/etc/nginx
- /usr/share/nginx/modules
- /var/run/nginx
- /var/log/nginx

command:
server:
host: managementPlane
port: 9092
type: grpc

collector:
additional_config_paths:
- "/etc/nginx-agent/my_config.yaml"
Loading
Loading