Skip to content

Commit

Permalink
Include metadata_registry in the E2E regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Jan 18, 2025
1 parent 0ef5fe5 commit 3ae8ad7
Show file tree
Hide file tree
Showing 17 changed files with 134,221 additions and 16,840 deletions.
1 change: 1 addition & 0 deletions .changelog/889.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable metadata_registry in the E2E regression tests
24 changes: 16 additions & 8 deletions analyzer/metadata_registry/metadata_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,36 @@ const MetadataRegistryAnalyzerName = "metadata_registry"
type processor struct {
target storage.TargetStorage
logger *log.Logger

gitCfg registry.GitConfig
mockLogoUrls bool
}

var _ item.ItemProcessor[struct{}] = (*processor)(nil)

func NewAnalyzer(
cfg config.ItemBasedAnalyzerConfig,
cfg config.MetadataRegistryConfig,
target storage.TargetStorage,
logger *log.Logger,
) (analyzer.Analyzer, error) {
logger.Info("Starting metadata_registry analyzer")
if cfg.Interval == 0 {
cfg.Interval = 2 * time.Minute
}
if cfg.Interval < time.Minute {
return nil, fmt.Errorf("invalid interval %s, metadata registry interval must be at least 1 minute", cfg.Interval)
}
logger = logger.With("analyzer", MetadataRegistryAnalyzerName)
p := &processor{
target: target,
logger: logger,
target: target,
logger: logger,
gitCfg: registry.NewGitConfig(),
mockLogoUrls: cfg.MockLogoUrls,
}
if cfg.RepositoryBranch != "" {
p.gitCfg.Branch = cfg.RepositoryBranch
}

return item.NewAnalyzer[struct{}](
MetadataRegistryAnalyzerName,
cfg,
cfg.ItemBasedAnalyzerConfig,
p,
target,
logger,
Expand All @@ -68,7 +73,7 @@ func (p *processor) GetItems(ctx context.Context, limit uint64) ([]struct{}, err
}

func (p *processor) ProcessItem(ctx context.Context, batch *storage.QueryBatch, item struct{}) error {
gp, err := registry.NewGitProvider(registry.NewGitConfig())
gp, err := registry.NewGitProvider(p.gitCfg)
if err != nil {
return fmt.Errorf("failed to create Git registry provider: %s", err)
}
Expand All @@ -91,6 +96,9 @@ func (p *processor) ProcessItem(ctx context.Context, batch *storage.QueryBatch,
return ctx.Err()
}
}
if p.mockLogoUrls {
logoUrl = "http:://e2e-tests-mock-static-logo-url"
}

batch.Queue(
queries.ConsensusEntityMetaUpsert,
Expand Down
2 changes: 1 addition & 1 deletion cmd/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func NewService(cfg *config.AnalysisConfig) (*Service, error) { //nolint:gocyclo
}
if cfg.Analyzers.MetadataRegistry != nil {
analyzers, err = addAnalyzer(analyzers, err, "" /*syncTag*/, func() (A, error) {
return metadata_registry.NewAnalyzer(cfg.Analyzers.MetadataRegistry.ItemBasedAnalyzerConfig, dbClient, logger)
return metadata_registry.NewAnalyzer(*cfg.Analyzers.MetadataRegistry, dbClient, logger)
})
}
if cfg.Analyzers.ValidatorStakingHistory != nil {
Expand Down
13 changes: 10 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,20 @@ type EvmAbiAnalyzerConfig struct {
// MetadataRegistryConfig is the configuration for the metadata registry analyzer.
type MetadataRegistryConfig struct {
ItemBasedAnalyzerConfig `koanf:",squash"`

// RepositoryBranch is the branch of the metadata registry repository to fetch.
// If unset, the default (production) branch is used. This is useful for E2E tests,
// where we use the 'nexus-e2e' branch, which remains stable.
RepositoryBranch string `koanf:"repository_branch"`

// MockLogoUrls is a flag to use mock URLs instead of keybase fetched URLs for logos.
// Useful to ensure static data for E2E testing since logo URLs can be updated without
// changes to the registry.
MockLogoUrls bool `koanf:"mock_logo_urls"`
}

// Validate validates the configuration.
func (cfg *MetadataRegistryConfig) Validate() error {
if cfg.Interval < time.Minute {
return fmt.Errorf("metadata registry interval must be at least 1 minute")
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e_regression/damask/e2e_config_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ analysis:
evm_abi_emerald: { stop_if_queue_empty_for: 10s } # Give evm_contract_verifier time to fetch ABIs first. The 10s has been enough in practice, but might need to be tuned in the future, espcially if the caching proxy has an empty cache.
evm_contract_verifier_emerald: { stop_if_queue_empty_for: 1s, sourcify_server_url: http://localhost:9191 }
validator_staking_history: { from: 8_048_956, stop_if_queue_empty_for: 1s, max_backoff_time: 6s }
metadata_registry: { interval: 5s, stop_if_queue_empty_for: 1s, repository_branch: "nexus-e2e", mock_logo_urls: true }
# Some non-block analyzers are not tested in e2e regressions.
# They are largely not worth the trouble as they do not interact with rest of the system much.
# metadata_registry: {} # Awkward to inject mock registry responses.
# node_stats: {} # Awkward to inject mock node response using the current paradigm (= response caching).
# aggregate_stats: {} # Awkward to make stop after a single run.
storage:
Expand Down
Loading

0 comments on commit 3ae8ad7

Please sign in to comment.