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

Move txdb and dialects to chainlink-common/pkg/pg #15064

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

reductionista
Copy link
Contributor

@reductionista reductionista commented Nov 1, 2024

NONEVM-739

Requires

smartcontractkit/chainlink-common#910

Description

This mostly just moves chainlink/core/internal/testutils/pgtest/txdb.go and chainlink/core/store/dialects/dialects.go into a new common package chainlink-common/pkg/pg, updating imports accordingly.
The purpose of this is so that it can be imported and used by chainlink-solana for unit testing Solana ORM's.

Since txdb.go was a bit of a mess, it has been cleaned up a bit.

  • The global init() function invoked on package load has been replaced with RegisterTxDb() which accepts a dbUrl as a param instead of automatically reading it from the CL_DATABASE env var. Since there are only two places in the codebase which depend on our custom txdb dialect of sql being registered, this can simply be called in both of those places (inside NewSqlxDb() and NewConnection()) instead of relying on the global init().
  • Prevents calling sql.Register() more than once if RegisterTxDb() is called more than once (calling sql.Register() more than once with the same driver name will result in an error).
  • Replaces passing of context.Background to queries with passing of a new context which gets cancelled if the context originally passed to NewSqlxDb is cancelled.
  • Corrected spelling errors

Copy link
Contributor

github-actions bot commented Nov 1, 2024

AER Report: CI Core

aer_workflow , commit , Detect Changes , Scheduled Run Frequency , Clean Go Tidy & Generate , Flakeguard Root Project / Get Tests To Run , lint , Core Tests (go_core_tests) , Core Tests (go_core_tests_integration) , Core Tests (go_core_ccip_deployment_tests) , Core Tests (go_core_race_tests) , Core Tests (go_core_fuzz) , Flakeguard Deployment Project / Get Tests To Run , Flakeguard Deployment Project / Run Tests , Flakeguard Deployment Project / Report , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/cmd,github.com/smartcontractkit/chainlin... , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/services/fluxmonitorv2,github.com/smartc... , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/services/directrequest,github.com/smartc... , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper,github.... , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/services/pipeline,github.com/smartcontra... , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/chains/evm/log,github.com/smartcontractk... , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/services/periodicbackup,github.com/smart... , Flakeguard Root Project / Run Tests (github.com/smartcontractkit/chainlink/v2/core/services/vrf/v2, ubuntu-latest) , Flakey Test Detection , SonarQube Scan , Flakeguard Root Project / Report

1. Test_disallowReplica failed due to missing import

[A 1 <= 10 words sentence that describes the error]:[job id where the error happened]
Test_disallowReplica failed due to missing import: Run tests with flakeguard

Source of Error:
connection_test.go:71: 
	Error Trace:	/home/runner/work/chainlink/chainlink/core/services/pg/connection_test.go:71
	Error: 	Received unexpected error:
	 	sql: unknown driver "txdb" (forgotten import?)
	Test: 	Test_disallowReplica
**Why**: The test `Test_disallowReplica` failed because the `txdb` driver was not imported, leading to an "unknown driver" error.

Suggested fix: Ensure that the txdb driver is imported in the test file where it is being used.

2. Linting issues found

[A 1 <= 10 words sentence that describes the error]:[job id where the error happened]
Linting issues found: Golang Lint

Source of Error:
core/services/chainlink/config_database_test.go:39:2: expected-actual: need to reverse actual and expected values (testifylint)
	assert.Equal(t, db.Dialect(), pgcommon.Postgres)
	^
**Why**: The linter found issues such as improper import formatting and incorrect order of arguments in assertions.

Suggested fix: Correct the import formatting to comply with goimports and reverse the order of actual and expected values in the assertion.

3. Ensure clean after generate failed

[A 1 <= 10 words sentence that describes the error]:[job id where the error happened]
Ensure clean after generate failed: Ensure clean after generate

Source of Error:
core/chains/evm/types/internal/blocks/internal_types_codecgen.go | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
**Why**: The `git diff --stat --cached --exit-code` command found changes in the generated files, indicating that the repository is not clean after running code generation.

Suggested fix: Commit the changes in the generated files or ensure that code generation does not produce any changes.

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

Copy link
Contributor

Flaky Test Detector for github.com/smartcontractkit/chainlink project has failed ❌

Ran new or updated tests between develop and ebe3258 (NONEVM-739/txdb).

View Flaky Detector Details | Compare Changes

Flaky Tests

Ran 2638 unique tests. Below are the tests identified as flaky, with a pass ratio lower than the 99% threshold:

TestPackage                                                       TestName                                               PassRatio  RunCount   Skipped
---------                                                         ---------                                              ---------  ---------  ---------
github.com/smartcontractkit/chainlink/v2/core/services/functions  TestFunctionsListener_ORMDoesNotFreezeHandlersForever  44%        3          false

Along with that:
- Replace dialects imports with pgcommon
- Replace testutils.Skip* with tests.Skip*
- Call RegisterTxDb from NewConnection
- Run goimports (somehow there were a few files on develop which were improperly formatted?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant