Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: E2E test failure with new namespace #1615

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion cmd/firefly.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func init() {
}

func resetConfig() {
coreconfig.Reset()
namespace.InitConfig()
apiserver.InitConfig()
}
Expand Down
1 change: 0 additions & 1 deletion doc-site/config_docs_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

func TestGenerateConfigDocs(t *testing.T) {
// Initialize config of all plugins
coreconfig.Reset()
namespace.InitConfig()
apiserver.InitConfig()
f, err := os.Create(filepath.Join("docs", "reference", "config.md"))
Expand Down
1 change: 0 additions & 1 deletion doc-site/config_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (

func TestConfigDocsUpToDate(t *testing.T) {
// Initialize config of all plugins
coreconfig.Reset()
namespace.InitConfig()
apiserver.InitConfig()
generatedConfig, err := config.GenerateConfigMarkdown(context.Background(), configDocHeader, config.GetKnownKeys())
Expand Down
7 changes: 0 additions & 7 deletions internal/apiserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import (
const configDir = "../../test/data/config"

func newTestServer() (*namespacemocks.Manager, *orchestratormocks.Orchestrator, *apiServer) {
coreconfig.Reset()
InitConfig()
mgr := &namespacemocks.Manager{}
o := &orchestratormocks.Orchestrator{}
Expand Down Expand Up @@ -81,7 +80,6 @@ func newTestSPIServer() (*orchestratormocks.Orchestrator, *mux.Router) {
}

func TestStartStopServer(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
apiConfig.Set(httpserver.HTTPConfPort, 0)
Expand All @@ -100,7 +98,6 @@ func TestStartStopServer(t *testing.T) {
}

func TestStartLegacyAdminConfig(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
apiConfig.Set(httpserver.HTTPConfPort, 0)
Expand All @@ -119,7 +116,6 @@ func TestStartLegacyAdminConfig(t *testing.T) {
}

func TestStartAPIFail(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
apiConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand All @@ -132,7 +128,6 @@ func TestStartAPIFail(t *testing.T) {
}

func TestStartAdminFail(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
spiConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand All @@ -148,7 +143,6 @@ func TestStartAdminFail(t *testing.T) {
}

func TestStartAdminWSHandler(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
spiConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand All @@ -167,7 +161,6 @@ func TestStartAdminWSHandler(t *testing.T) {
}

func TestStartMetricsFail(t *testing.T) {
coreconfig.Reset()
metrics.Clear()
InitConfig()
metricsConfig.Set(httpserver.HTTPConfAddress, "...://")
Expand Down
1 change: 0 additions & 1 deletion internal/apiserver/swagger_check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
)

func TestDiffSwaggerYAML(t *testing.T) {
coreconfig.Reset()
config.Set(coreconfig.APIOASPanicOnMissingDescription, true)
as := &apiServer{}
hf := as.handlerFactory()
Expand Down
1 change: 0 additions & 1 deletion internal/apiserver/swagger_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
)

func TestDownloadSwaggerYAML(t *testing.T) {
coreconfig.Reset()
config.Set(coreconfig.APIOASPanicOnMissingDescription, true)
as := &apiServer{}
hf := as.handlerFactory()
Expand Down
5 changes: 0 additions & 5 deletions internal/assets/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func newTestAssetsWithMetrics(t *testing.T) (*assetManager, func()) {
}

func newTestAssetsCommon(t *testing.T, metrics bool) (*assetManager, func()) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mim := &identitymanagermocks.Manager{}
mdm := &datamocks.Manager{}
Expand Down Expand Up @@ -91,7 +90,6 @@ func TestInitFail(t *testing.T) {

func TestCacheInitFail(t *testing.T) {
cacheInitError := errors.New("Initialization error.")
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand Down Expand Up @@ -163,7 +161,6 @@ func TestGetTokenConnectors(t *testing.T) {
}

func TestStart(t *testing.T) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand Down Expand Up @@ -193,7 +190,6 @@ func TestStart(t *testing.T) {
}

func TestStartDBError(t *testing.T) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand All @@ -216,7 +212,6 @@ func TestStartDBError(t *testing.T) {
}

func TestStartError(t *testing.T) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mdm := &datamocks.Manager{}
mim := &identitymanagermocks.Manager{}
Expand Down
1 change: 0 additions & 1 deletion internal/batch/batch_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
)

func testConfigReset() {
coreconfig.Reset()
config.Set(coreconfig.BatchManagerMinimumPollDelay, "0")
log.SetLevel("debug")
}
Expand Down
7 changes: 0 additions & 7 deletions internal/batch/batch_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func (tce *testConflictError) IsConflictError() bool {

func TestUnfilledBatch(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -154,7 +153,6 @@ func TestHandleDispatchConflictError(t *testing.T) {

func TestBatchSizeOverflow(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -553,7 +551,6 @@ func TestStartQuiesceNonBlocking(t *testing.T) {

func TestMarkMessageDispatchedUnpinnedOK(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -611,7 +608,6 @@ func TestMarkMessageDispatchedUnpinnedOK(t *testing.T) {

func TestMaskContextsRetryAfterPinsAssigned(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -681,7 +677,6 @@ func TestMaskContextsRetryAfterPinsAssigned(t *testing.T) {

func TestMaskContextsUpdateMessageFail(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -720,7 +715,6 @@ func TestMaskContextsUpdateMessageFail(t *testing.T) {
}

func TestSealBatchTXAlreadyAssigned(t *testing.T) {
coreconfig.Reset()

dispatched := make(chan *DispatchPayload)
cancel, mdi, bp := newTestBatchProcessor(t, func(c context.Context, state *DispatchPayload) error {
Expand Down Expand Up @@ -831,7 +825,6 @@ func TestCalculateContextsLoadPinsFail(t *testing.T) {

func TestBigBatchEstimate(t *testing.T) {
log.SetLevel("debug")
coreconfig.Reset()

bd := []byte(`{
"id": "37ba893b-fcfa-4cf9-8ce8-34cd8bc9bc72",
Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/ethereum/address_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
)

func utAddresResolverConfig() config.Section {
coreconfig.Reset()
config := config.RootSection("utaddressresovler")
(&Ethereum{}).InitConfig(config)
return config.SubSection(AddressResolverConfigKey)
Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/ethereum/ethereum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func testFFIErrors() []*fftypes.FFIError {
}

func resetConf(e *Ethereum) {
coreconfig.Reset()
e.InitConfig(utConfig)
}

Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/fabric/fabric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ var utFabconnectConf = utConfig.SubSection(FabconnectConfigKey)
var signer = "orgMSP::x509::CN=signer001,OU=client::CN=fabric-ca"

func resetConf(e *Fabric) {
coreconfig.Reset()
e.InitConfig(utConfig)
}

Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/tezos/address_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
)

func utAddresResolverConfig() config.Section {
coreconfig.Reset()
config := config.RootSection("utaddressresovler")
(&Tezos{}).InitConfig(config)
return config.SubSection(AddressResolverConfigKey)
Expand Down
1 change: 0 additions & 1 deletion internal/blockchain/tezos/tezos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func testFFIMethod() *fftypes.FFIMethod {
}

func resetConf(t *Tezos) {
coreconfig.Reset()
t.InitConfig(utConfig)
}

Expand Down
1 change: 0 additions & 1 deletion internal/broadcast/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
)

func newTestBroadcastCommon(t *testing.T, metricsEnabled bool) (*broadcastManager, func()) {
coreconfig.Reset()
mdi := &databasemocks.Plugin{}
mim := &identitymanagermocks.Manager{}
mdm := &datamocks.Manager{}
Expand Down
5 changes: 0 additions & 5 deletions internal/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
)

func TestNewCacheCreationFail(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
_, err := cacheManager.GetCache(NewCacheConfig(ctx, "", "", ""))
Expand All @@ -41,7 +40,6 @@ func TestNewCacheCreationFail(t *testing.T) {
}

func TestGetCacheReturnsSameCacheForSameConfig(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
cache0, _ := cacheManager.GetCache(NewCacheConfig(ctx, "cache.batch.limit", "cache.batch.ttl", "testnamespace"))
Expand All @@ -57,7 +55,6 @@ func TestGetCacheReturnsSameCacheForSameConfig(t *testing.T) {
}

func TestTwoSeparateCacheWorksIndependently(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
cache0, _ := cacheManager.GetCache(NewCacheConfig(ctx, "cache.batch.limit", "cache.batch.ttl", ""))
Expand All @@ -77,7 +74,6 @@ func TestTwoSeparateCacheWorksIndependently(t *testing.T) {
}

func TestReturnsDummyCacheWhenCacheDisabled(t *testing.T) {
coreconfig.Reset()
config.Set(coreconfig.CacheEnabled, false)
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
Expand All @@ -93,7 +89,6 @@ func TestUmmanagedCacheInstance(t *testing.T) {
}

func TestResetCachesForNamespace(t *testing.T) {
coreconfig.Reset()
ctx := context.Background()
cacheManager := NewCacheManager(ctx)
cacheNS1, _ := cacheManager.GetCache(NewCacheConfig(ctx, "cache.batch.limit", "cache.batch.ttl", "ns1"))
Expand Down
4 changes: 0 additions & 4 deletions internal/coreconfig/coreconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,3 @@ func setDefaults() {
viper.SetDefault(string(CacheTokenPoolLimit), 100)
viper.SetDefault(string(CacheTokenPoolTTL), "1h")
}

func Reset() {
config.RootConfigReset(setDefaults)
}
Comment on lines -478 to -481
Copy link
Contributor

@EnriqueL8 EnriqueL8 Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to check where this is being used as it is and failing the CI

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do coreconfig.Reset() and Reset() mean the same this. I noticed the difference in syntax and was not certain if this was a separate function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah they are the same function. The other file is calling the Reset() that you just deleted in the coreconfig pkg

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so I would need to remove them from there also correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that is correct

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed them :). I did remove the additional calls to Reset that were made in additional files as well. I came across internal/events/event_manager_test.go and I noticed there is a line that reads "defer coreconfig.Reset()". I am wondering if the best step is to remove the "defer" keyword? I am still learning GO and from what I understand this word must follow a function or method call. If its not removed would I add this word before "mdi := &databasemocks.Plugin{}" ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So defer will run when the function exists. I think we can remove all the places where that old reset API is called and instead rely on the file system reload

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, I will remove the additional lines. Thank you!

1 change: 0 additions & 1 deletion internal/coreconfig/coreconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
const configDir = "../../test/data/config"

func TestInitConfigOK(t *testing.T) {
Reset()

assert.Equal(t, 25, config.GetInt(APIDefaultFilterLimit))
assert.Equal(t, "localhost", config.GetString(DebugAddress))
Expand Down
5 changes: 0 additions & 5 deletions internal/data/data_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (

func TestCacheInitFail(t *testing.T) {
cacheInitError := errors.New("Initialization error.")
coreconfig.Reset()
config.Set(coreconfig.MessageWriterCount, 1)
ctx := context.Background()
mdi := &databasemocks.Plugin{}
Expand Down Expand Up @@ -80,7 +79,6 @@ func TestCacheInitFail(t *testing.T) {
}

func newTestDataManager(t *testing.T) (*dataManager, context.Context, func()) {
coreconfig.Reset()
config.Set(coreconfig.MessageWriterCount, 1)
ctx, cancel := context.WithCancel(context.Background())
mdi := &databasemocks.Plugin{}
Expand Down Expand Up @@ -134,7 +132,6 @@ func testNewMessage() (*fftypes.UUID, *fftypes.Bytes32, *NewMessage) {

func TestValidateE2E(t *testing.T) {

coreconfig.Reset()
dm, ctx, cancel := newTestDataManager(t)
defer cancel()
mdi := dm.database.(*databasemocks.Plugin)
Expand Down Expand Up @@ -281,7 +278,6 @@ func TestInitBadDeps(t *testing.T) {
}

func TestValidatorLookupCached(t *testing.T) {
coreconfig.Reset()
dm, ctx, cancel := newTestDataManager(t)
defer cancel()
mdi := dm.database.(*databasemocks.Plugin)
Expand Down Expand Up @@ -309,7 +305,6 @@ func TestValidatorLookupCached(t *testing.T) {

func TestValidateBadHash(t *testing.T) {

coreconfig.Reset()
dm, ctx, cancel := newTestDataManager(t)
defer cancel()
mdi := dm.database.(*databasemocks.Plugin)
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/chart_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func TestGetChartHistogramValidCollectionNameWithTypes(t *testing.T) {

func TestGetChartHistogramValidCollectionNameWithTypesAndCapped(t *testing.T) {
s, mock := newMockProvider().init()
coreconfig.Reset()
config.Set(coreconfig.HistogramsMaxChartRows, 10)
for i := range validCollectionsWithTypes {
mock.ExpectQuery("SELECT .*").WillReturnRows(sqlmock.NewRows([]string{"timestamp", "type"}).
Expand Down
1 change: 0 additions & 1 deletion internal/database/sqlcommon/provider_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type mockProvider struct {
}

func newMockProvider() *mockProvider {
coreconfig.Reset()
conf := config.RootSection("unittest.db")
conf.AddKnownKey("url", "test")
mp := &mockProvider{
Expand Down
Loading