generated from TrueCloudLab/basic
Aleksey Savaitan
db6cf1ea16
All checks were successful
DCO action / DCO (pull_request) Successful in 45s
Tests and linters / Tests (1.21) (pull_request) Successful in 1m38s
Tests and linters / Tests (1.22) (pull_request) Successful in 1m38s
Tests and linters / Tests with -race (pull_request) Successful in 1m42s
Tests and linters / Staticcheck (pull_request) Successful in 1m50s
Tests and linters / Lint (pull_request) Successful in 2m0s
Signed-off-by: Aleksey Savaitan <a.savaitan@yadro.com>
121 lines
3.3 KiB
Go
121 lines
3.3 KiB
Go
package tracing_test
|
|
|
|
import (
|
|
"context"
|
|
"github.com/stretchr/testify/require"
|
|
"testing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/testdata"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
|
)
|
|
|
|
func TestSetup(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
config tracing.Config
|
|
want bool
|
|
expErr error
|
|
}{
|
|
{
|
|
name: "setup stdout exporter",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.StdoutExporter,
|
|
Service: "service-name",
|
|
},
|
|
want: true,
|
|
expErr: nil,
|
|
},
|
|
{
|
|
name: "setup noop exporter",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.NoOpExporter,
|
|
Service: "service-name",
|
|
},
|
|
|
|
want: true,
|
|
expErr: nil,
|
|
},
|
|
{
|
|
name: "setup otlp_grpc insecure exporter",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.OTLPgRPCExporter,
|
|
Service: "service-name",
|
|
Endpoint: "test-endpoint.com:4317",
|
|
},
|
|
want: true,
|
|
expErr: nil,
|
|
},
|
|
{
|
|
name: "setup otlp_grpc secure exporter with valid rsa root ca certificate",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.OTLPgRPCExporter,
|
|
Service: "service-name",
|
|
Endpoint: "test-endpoint.com:4317",
|
|
ServerCaCertPath: testdata.Path("tracing/setup/valid_google_globalsign_r4_rsa_root_ca.pem"),
|
|
},
|
|
want: true,
|
|
expErr: nil,
|
|
},
|
|
{
|
|
name: "setup otlp_grpc secure exporter with valid ecdsa root ca certificate",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.OTLPgRPCExporter,
|
|
Service: "service-name",
|
|
Endpoint: "test-endpoint.com:4317",
|
|
ServerCaCertPath: testdata.Path("tracing/setup/valid_google_gts_r4_ecdsa_root_ca.pem"),
|
|
},
|
|
want: true,
|
|
expErr: nil,
|
|
},
|
|
{
|
|
name: "setup otlp_grpc secure exporter with invalid empty root ca certificate",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.OTLPgRPCExporter,
|
|
Service: "service-name",
|
|
Endpoint: "test-endpoint.com:4317",
|
|
ServerCaCertPath: testdata.Path("tracing/setup/invalid_empty_root_ca.pem"),
|
|
},
|
|
want: false,
|
|
expErr: tracing.ErrInvalidServerRootCaCertificate,
|
|
},
|
|
{
|
|
name: "setup otlp_grpc secure exporter with invalid root ca certificate",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.OTLPgRPCExporter,
|
|
Service: "service-name",
|
|
Endpoint: "test-endpoint.com:4317",
|
|
ServerCaCertPath: testdata.Path("tracing/setup/invalid_root_ca.pem"),
|
|
},
|
|
want: false,
|
|
expErr: tracing.ErrInvalidServerRootCaCertificate,
|
|
},
|
|
{
|
|
name: "setup otlp_grpc secure exporter with invalid path root ca certificate",
|
|
config: tracing.Config{
|
|
Enabled: true,
|
|
Exporter: tracing.OTLPgRPCExporter,
|
|
Service: "service-name",
|
|
Endpoint: "test-endpoint.com:4317",
|
|
ServerCaCertPath: testdata.Path(""),
|
|
},
|
|
want: false,
|
|
expErr: tracing.ErrInvalidServerRootCaCertificate,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := tracing.Setup(context.Background(), tt.config)
|
|
require.ErrorIs(t, err, tt.expErr)
|
|
if got != tt.want {
|
|
t.Errorf("Setup config = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|