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

add chainlink health command; make DB available for testscript client/server tests #11591

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Dec 15, 2023

Add a chainlink health command to print the health status in plaintext or json.

Also rigged up database usage for the testscript/txtar tests, so that we can test client/server interaction.

$ chainlink health
-Cosmos.Foo.Chain
-Cosmos.Foo.Txm
-EVM.1
-EVM.1.BalanceMonitor
-EVM.1.HeadBroadcaster
-EVM.1.HeadTracker
!EVM.1.HeadTracker.HeadListener
	Listener is not connected
-EVM.1.LogBroadcaster
-EVM.1.Txm
-EVM.1.Txm.BlockHistoryEstimator
-EVM.1.Txm.Broadcaster
-EVM.1.Txm.Confirmer
-EVM.1.Txm.WrappedEvmEstimator
-EventBroadcaster
-JobSpawner
-Mailbox.Monitor
-Mercury.WSRPCPool
-Mercury.WSRPCPool.CacheSet
-PipelineORM
-PipelineRunner
-PromReporter
-Solana.Bar
-StarkNet.Baz
-TelemetryManager

Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@jmank88 jmank88 changed the title add chainlink health command; make DB avialable for testscript client/server tests add chainlink health command; make DB available for testscript client/server tests Dec 17, 2023
main_test.go Outdated Show resolved Hide resolved
@jmank88 jmank88 force-pushed the health-cmd branch 3 times, most recently from f1079e1 to 0f1c3a1 Compare January 1, 2024 14:59
@jmank88 jmank88 requested review from chudilka1 and a team January 1, 2024 15:01
CL_DATABASE_URL

-- password --
T.tLHkcmwePT/p,]sYuntjwHKAsrhm#4eRs4LuKHwvHejWYAC2JP4M8HimwgmbaZ
Copy link
Contributor

Choose a reason for hiding this comment

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

:)

@jmank88 jmank88 force-pushed the health-cmd branch 9 times, most recently from 6974109 to fe3581e Compare January 4, 2024 13:33
Comment on lines +50 to +52
KindEmpty Kind = iota
KindTemplate
KindFixtures
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I always had a hard time reading these funcs, but never looked too closely before. The bool params were not only hard to read, but also mutually exclusive. IMHO it is simpler to combine them in to one option. Before combining, I had just moved them to a separate config struct, so here I ended up settling on a method instead of a func. I considered undoing that, but FWIW this way is nicer for callers outside the package, since it avoids repeating the long package name:

cfg, db := heavyweight.KindEmpty.PrepareDB(t, nil)

vs.

cfg, db := heavyweight.PrepareDB(t, heavyweight.KindEmpty, nil)

@jmank88 jmank88 marked this pull request as ready for review January 4, 2024 14:28
@jmank88 jmank88 requested a review from a team January 4, 2024 14:28
te.Setenv("VERSION", static.Version)
te.Setenv("COMMIT_SHA", static.Sha)

b, err := os.ReadFile(filepath.Join(te.WorkDir, testPortName))
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to read a file here? the file name is testPortName?

does the envVarName need to be dynamic? does each test get a clean env? can we use something fixed and obvious like ~ TX_TEST_PORT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed a mechanism to request these optionally, and I was thinking that more advanced tests could require more than one port or DB, in which case this can easily expand to parse multiple lines 🤷

@cl-sonarqube-production
Copy link

//
// -- testdb.txt --
// CL_DATABASE_URL
testDBName = "testdb.txt"
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't see these files in the PR. what's happening? are tests dynamically creating them or something?

Copy link
Contributor Author

@jmank88 jmank88 Jan 4, 2024

Choose a reason for hiding this comment

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

They are embedded in the *.txtar files as described in the comment:

-- testdb.txt --
CL_DATABASE_URL

if err != nil {
return s.errorOut(err)
}
fmt.Println(string(b))
Copy link
Contributor

Choose a reason for hiding this comment

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

is this print intentional? No formatting?

Copy link
Contributor Author

@jmank88 jmank88 Jan 4, 2024

Choose a reason for hiding this comment

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

Correct. No formatting necessary. Either it is already plaintext, or they requested raw JSON via the flag anyways. We could pretty print the JSON, but the text version is already the human formatted version of the JSON, and it is trivial for them to use | jq if they really need that anyways.

@jmank88 jmank88 added this pull request to the merge queue Jan 4, 2024
Merged via the queue into develop with commit 2f10153 Jan 4, 2024
78 checks passed
@jmank88 jmank88 deleted the health-cmd branch January 4, 2024 18:04
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.

5 participants