Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b9ca00b
fixed test-node default activation
dean-amar Mar 3, 2026
7e95704
* fixed release-image based test.
dean-amar Mar 3, 2026
9a20569
* minor change.
dean-amar Mar 3, 2026
06727fc
* rebased.
dean-amar Mar 9, 2026
859521b
* sample config point directly to the artifacts path
dean-amar Mar 10, 2026
568ec03
* addressed PR comments.
dean-amar Mar 11, 2026
127d225
* rebased.
dean-amar Mar 11, 2026
02bcdc0
* addressed PR comments.
dean-amar Mar 11, 2026
590a71c
* fixed minor issues.
dean-amar Mar 11, 2026
c38dd83
* Fix race condition in container tests by removing chown commands
dean-amar Mar 11, 2026
cf8e0f0
* rebased.
dean-amar Mar 11, 2026
260632f
* rebased.
dean-amar Mar 11, 2026
38ef814
* revert db creds creation by crypto material.
dean-amar Mar 11, 2026
0cebb7a
* remove db's tls credentials created by the cryptogen tool.
dean-amar Mar 11, 2026
211aad3
* Addressed PR comments.
dean-amar Mar 15, 2026
4f4a1e4
* Addressed PR comments - not finished.
dean-amar Mar 15, 2026
5427d63
* Addressed PR comments.
dean-amar Mar 15, 2026
2dcba87
* fixed read while write db's TLS creds.
dean-amar Mar 15, 2026
cbe7244
* fix linter.
dean-amar Mar 15, 2026
9f23b3f
* addressed PR's comments - final.
dean-amar Mar 16, 2026
1115540
* rebased.
dean-amar Mar 16, 2026
761cf9d
* comments enhancements.
dean-amar Mar 16, 2026
29f198b
* addressed Liran's comments.
dean-amar Mar 16, 2026
f905227
* removed common-ca-cert-paths
dean-amar Mar 16, 2026
81fbcf9
* minor fix.
dean-amar Mar 16, 2026
e19ea9f
* renamed CreateServerTLSConfig to NewServiceTLSConfig.
dean-amar Mar 16, 2026
946996d
* minor fix.
dean-amar Mar 16, 2026
d774388
* removed unnecessary comment.
dean-amar Mar 16, 2026
aef0afc
* rebased + addressed config comment.
dean-amar Mar 17, 2026
f3c4c8f
* fixed minor config issue.
dean-amar Mar 17, 2026
f159ad5
* crypto-files tree updated.
dean-amar Mar 17, 2026
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
143 changes: 62 additions & 81 deletions cmd/config/app_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,18 @@ import (
"github.com/hyperledger/fabric-x-committer/utils/dbconn"
"github.com/hyperledger/fabric-x-committer/utils/ordererconn"
"github.com/hyperledger/fabric-x-committer/utils/signature"
"github.com/hyperledger/fabric-x-committer/utils/test"
)

var (
defaultServerTLSConfig = connection.TLSConfig{
Mode: connection.MutualTLSMode,
CertPath: "/server-certs/public-key.pem",
KeyPath: "/server-certs/private-key.pem",
CACertPaths: []string{
"/server-certs/ca-certificate.pem",
},
}
defaultClientTLSConfig = connection.TLSConfig{
Mode: connection.MutualTLSMode,
CertPath: "/client-certs/public-key.pem",
KeyPath: "/client-certs/private-key.pem",
CACertPaths: []string{
"/client-certs/ca-certificate.pem",
},
}
)
const artifactsPath = "/root/artifacts"
Comment thread
dean-amar marked this conversation as resolved.

const ordererRootCA = "/client-certs/orderer-ca-certificate.pem"
var ordererRootCAs = []string{
filepath.Join(artifactsPath, test.OrdererRootCATLSPath),
}

func TestReadConfigSidecar(t *testing.T) {
t.Parallel()
sidecarTLSCreds := test.NewServiceTLSConfig(artifactsPath, "sidecar", connection.MutualTLSMode)
tests := []struct {
name string
configFilePath string
Expand Down Expand Up @@ -92,7 +79,7 @@ func TestReadConfigSidecar(t *testing.T) {
expectedConfig: &sidecar.Config{
Server: &connection.ServerConfig{
Endpoint: *newEndpoint("", 4001),
TLS: defaultServerTLSConfig,
TLS: sidecarTLSCreds,
KeepAlive: &connection.ServerKeepAliveConfig{
Params: &connection.ServerKeepAliveParamsConfig{
Time: 300 * time.Second,
Expand All @@ -105,26 +92,25 @@ func TestReadConfigSidecar(t *testing.T) {
},
MaxConcurrentStreams: 10,
},
Monitoring: newServerConfigWithDefaultTLS(2114),
Monitoring: newServerConfigWithDefaultTLS("sidecar", 2114),
Orderer: ordererconn.Config{
ChannelID: "mychannel",
TLS: ordererconn.OrdererTLSConfig{
Mode: defaultClientTLSConfig.Mode,
KeyPath: defaultClientTLSConfig.KeyPath,
CertPath: defaultClientTLSConfig.CertPath,
CommonCACertPaths: defaultClientTLSConfig.CACertPaths,
Mode: sidecarTLSCreds.Mode,
KeyPath: sidecarTLSCreds.KeyPath,
CertPath: sidecarTLSCreds.CertPath,
},
Organizations: map[string]*ordererconn.OrganizationConfig{
"org0": {
Endpoints: []*commontypes.OrdererEndpoint{
newOrdererEndpoint("", "orderer"),
},
CACerts: defaultClientTLSConfig.CACertPaths,
CACerts: ordererRootCAs,
},
},
Identity: newIdentityConfig(),
},
Committer: newClientConfigWithDefaultTLS("coordinator", 9001),
Committer: newClientConfigWithDefaultTLS("coordinator", "sidecar", 9001),
Ledger: sidecar.LedgerConfig{
Path: "/root/sc/ledger",
SyncInterval: 100,
Expand All @@ -142,13 +128,13 @@ func TestReadConfigSidecar(t *testing.T) {
},
},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
v := NewViperWithSidecarDefaults()
c, err := ReadSidecarYamlAndSetupLogging(v, tt.configFilePath)
c, err := ReadSidecarYamlAndSetupLogging(v, tc.configFilePath)
require.NoError(t, err)
require.Equal(t, tt.expectedConfig, c)
require.Equal(t, tc.expectedConfig, c)
})
}
}
Expand All @@ -175,10 +161,10 @@ func TestReadConfigCoordinator(t *testing.T) {
name: "sample",
configFilePath: "samples/coordinator.yaml",
expectedConfig: &coordinator.Config{
Server: newServerConfigWithDefaultTLS(9001),
Monitoring: newServerConfigWithDefaultTLS(2119),
Verifier: newMultiClientConfigWithDefaultTLS("verifier", 5001),
ValidatorCommitter: newMultiClientConfigWithDefaultTLS("vc", 6001),
Server: newServerConfigWithDefaultTLS("coordinator", 9001),
Monitoring: newServerConfigWithDefaultTLS("coordinator", 2119),
Verifier: newMultiClientConfigWithDefaultTLS("verifier", "coordinator", 5001),
ValidatorCommitter: newMultiClientConfigWithDefaultTLS("vc", "coordinator", 6001),
DependencyGraph: &coordinator.DependencyGraphConfig{
NumOfLocalDepConstructors: 1,
WaitingTxsLimit: 100_000,
Expand All @@ -187,14 +173,13 @@ func TestReadConfigCoordinator(t *testing.T) {
},
}}

for _, test := range tests {
tt := test
t.Run(tt.name, func(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
v := NewViperWithCoordinatorDefaults()
c, err := ReadCoordinatorYamlAndSetupLogging(v, tt.configFilePath)
c, err := ReadCoordinatorYamlAndSetupLogging(v, tc.configFilePath)
require.NoError(t, err)
require.Equal(t, tt.expectedConfig, c)
require.Equal(t, tc.expectedConfig, c)
})
}
}
Expand Down Expand Up @@ -224,8 +209,8 @@ func TestReadConfigVC(t *testing.T) {
name: "sample",
configFilePath: "samples/vc.yaml",
expectedConfig: &vc.Config{
Server: newServerConfigWithDefaultTLS(6001),
Monitoring: newServerConfigWithDefaultTLS(2116),
Server: newServerConfigWithDefaultTLS("vc", 6001),
Monitoring: newServerConfigWithDefaultTLS("vc", 2116),
Database: defaultSampleDBConfig(),
ResourceLimits: &vc.ResourceLimitsConfig{
MaxWorkersForPreparer: 1,
Expand All @@ -237,14 +222,13 @@ func TestReadConfigVC(t *testing.T) {
},
}}

for _, test := range tests {
tt := test
t.Run(tt.name, func(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
v := NewViperWithVCDefaults()
c, err := ReadVCYamlAndSetupLogging(v, tt.configFilePath)
c, err := ReadVCYamlAndSetupLogging(v, tc.configFilePath)
require.NoError(t, err)
require.Equal(t, tt.expectedConfig, c)
require.Equal(t, tc.expectedConfig, c)
})
}
}
Expand Down Expand Up @@ -272,8 +256,8 @@ func TestReadConfigVerifier(t *testing.T) {
name: "sample",
configFilePath: "samples/verifier.yaml",
expectedConfig: &verifier.Config{
Server: newServerConfigWithDefaultTLS(5001),
Monitoring: newServerConfigWithDefaultTLS(2115),
Server: newServerConfigWithDefaultTLS("verifier", 5001),
Monitoring: newServerConfigWithDefaultTLS("verifier", 2115),
ParallelExecutor: verifier.ExecutorConfig{
BatchSizeCutoff: 50,
BatchTimeCutoff: 10 * time.Millisecond,
Expand All @@ -283,14 +267,13 @@ func TestReadConfigVerifier(t *testing.T) {
},
}}

for _, test := range tests {
tt := test
t.Run(tt.name, func(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
v := NewViperWithVerifierDefaults()
c, err := ReadVerifierYamlAndSetupLogging(v, tt.configFilePath)
c, err := ReadVerifierYamlAndSetupLogging(v, tc.configFilePath)
require.NoError(t, err)
require.Equal(t, tt.expectedConfig, c)
require.Equal(t, tc.expectedConfig, c)
})
}
}
Expand Down Expand Up @@ -326,8 +309,8 @@ func TestReadConfigQuery(t *testing.T) {
name: "sample",
configFilePath: "samples/query.yaml",
expectedConfig: &query.Config{
Server: newServerConfigWithDefaultTLS(7001),
Monitoring: newServerConfigWithDefaultTLS(2117),
Server: newServerConfigWithDefaultTLS("query", 7001),
Monitoring: newServerConfigWithDefaultTLS("query", 2117),
Database: defaultSampleDBConfig(),
MinBatchKeys: 1024,
MaxBatchWait: 100 * time.Millisecond,
Expand All @@ -339,20 +322,20 @@ func TestReadConfigQuery(t *testing.T) {
},
}}

for _, test := range tests {
tt := test
t.Run(tt.name, func(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
v := NewViperWithQueryDefaults()
c, err := ReadQueryYamlAndSetupLogging(v, tt.configFilePath)
c, err := ReadQueryYamlAndSetupLogging(v, tc.configFilePath)
require.NoError(t, err)
require.Equal(t, tt.expectedConfig, c)
require.Equal(t, tc.expectedConfig, c)
})
}
}

func TestReadConfigLoadGen(t *testing.T) {
t.Parallel()
loadgenTLSCreds := test.NewServiceTLSConfig(artifactsPath, "loadgen", connection.MutualTLSMode)
tests := []struct {
name string
configFilePath string
Expand All @@ -370,10 +353,10 @@ func TestReadConfigLoadGen(t *testing.T) {
name: "sample",
configFilePath: "samples/loadgen.yaml",
expectedConfig: &loadgen.ClientConfig{
Server: newServerConfigWithDefaultTLS(8001),
Server: newServerConfigWithDefaultTLS("loadgen", 8001),
HTTPServer: newServerConfig("", 6997),
Monitoring: metrics.Config{
ServerConfig: *newServerConfigWithDefaultTLS(2118),
ServerConfig: *newServerConfigWithDefaultTLS("loadgen", 2118),
Latency: metrics.LatencyConfig{
SamplerConfig: metrics.SamplerConfig{
Portion: 0.01,
Expand All @@ -387,23 +370,22 @@ func TestReadConfigLoadGen(t *testing.T) {
},
Adapter: adapters.AdapterConfig{
OrdererClient: &adapters.OrdererClientConfig{
SidecarClient: newClientConfigWithDefaultTLS("sidecar", 4001),
SidecarClient: newClientConfigWithDefaultTLS("sidecar", "loadgen", 4001),
Orderer: ordererconn.Config{
ChannelID: "mychannel",
ConsensusType: ordererconn.Bft,
Identity: newIdentityConfig(),
TLS: ordererconn.OrdererTLSConfig{
Mode: defaultClientTLSConfig.Mode,
KeyPath: defaultClientTLSConfig.KeyPath,
CertPath: defaultClientTLSConfig.CertPath,
CommonCACertPaths: defaultClientTLSConfig.CACertPaths,
Mode: loadgenTLSCreds.Mode,
KeyPath: loadgenTLSCreds.KeyPath,
CertPath: loadgenTLSCreds.CertPath,
},
Organizations: map[string]*ordererconn.OrganizationConfig{
"org0": {
Endpoints: []*commontypes.OrdererEndpoint{
newOrdererEndpoint("", "orderer"),
},
CACerts: []string{ordererRootCA},
CACerts: ordererRootCAs,
},
},
},
Expand Down Expand Up @@ -454,14 +436,13 @@ func TestReadConfigLoadGen(t *testing.T) {
},
}}

for _, test := range tests {
tt := test
t.Run(tt.name, func(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
v := NewViperWithLoadGenDefaults()
c, err := ReadLoadGenYamlAndSetupLogging(v, tt.configFilePath)
c, err := ReadLoadGenYamlAndSetupLogging(v, tc.configFilePath)
require.NoError(t, err)
require.Equal(t, tt.expectedConfig, c)
require.Equal(t, tc.expectedConfig, c)
})
}
}
Expand All @@ -488,7 +469,7 @@ func defaultSampleDBConfig() *vc.DatabaseConfig {
Database: "yugabyte",
TLS: dbconn.DatabaseTLSConfig{
Mode: connection.OneSideTLSMode,
CACertPath: "/server-certs/ca-certificate.pem",
CACertPath: filepath.Join(artifactsPath, test.OrgRootCA),
},
MaxConnections: 10,
MinConnections: 5,
Expand All @@ -503,26 +484,26 @@ func defaultSampleDBConfig() *vc.DatabaseConfig {
}
}

func newClientConfigWithDefaultTLS(host string, port int) *connection.ClientConfig {
func newClientConfigWithDefaultTLS(host, fromService string, port int) *connection.ClientConfig {
return &connection.ClientConfig{
Endpoint: newEndpoint(host, port),
TLS: defaultClientTLSConfig,
TLS: test.NewServiceTLSConfig(artifactsPath, fromService, connection.MutualTLSMode),
}
}

func newMultiClientConfigWithDefaultTLS(host string, port int) connection.MultiClientConfig {
func newMultiClientConfigWithDefaultTLS(host, fromService string, port int) connection.MultiClientConfig {
return connection.MultiClientConfig{
Endpoints: []*connection.Endpoint{
newEndpoint(host, port),
},
TLS: defaultClientTLSConfig,
TLS: test.NewServiceTLSConfig(artifactsPath, fromService, connection.MutualTLSMode),
}
}

func newServerConfigWithDefaultTLS(port int) *connection.ServerConfig {
func newServerConfigWithDefaultTLS(serviceName string, port int) *connection.ServerConfig {
return &connection.ServerConfig{
Endpoint: *newEndpoint("", port),
TLS: defaultServerTLSConfig,
TLS: test.NewServiceTLSConfig(artifactsPath, serviceName, connection.MutualTLSMode),
}
}

Expand Down
Loading
Loading