Skip to content

Conversation

@joao-r-reis
Copy link
Contributor

@joao-r-reis joao-r-reis commented Jun 13, 2025

Also renamed NewHostInfo to NewHostInfoFromContactPoint, this isn't a breaking change because this function was exported recently and no release has gone out since then.

What is a breaking change is making host.SetHostID private, I don't see why we would let users modify the host id

@joao-r-reis joao-r-reis requested a review from jameshartig June 13, 2025 16:18
@joao-r-reis joao-r-reis force-pushed the cassgo71-hostfilter-testable branch 2 times, most recently from 5d5f2be to 7a91ba4 Compare June 13, 2025 16:31
Copy link
Contributor

@jameshartig jameshartig left a comment

Choose a reason for hiding this comment

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

Just a few minor comments

host_source.go Outdated
//
// If you're looking for a way to create a HostInfo object with more than just an address and port for
// testing purposes then you can use NewTestHostInfoFromRow
func NewHostInfoFromContactPoint(addr net.IP, port int) (*HostInfo, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: What's the reason behind "ContactPoint"? What about "NewHostInfoFromAddrPort"? Not terribly opposed with contact point though

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 checked and the only time we create host info objects from Addr and Port is during init when we are converting contact points into HostPoints, everywhere else we always use the row from the system table. I'm ok with changing to NewHostInfoFromAddrPort though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it

// "native_port": 9042,
// }
// host, err := NewTestHostInfoFromRow(row)
func NewTestHostInfoFromRow(row map[string]interface{}) (*HostInfo, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have the same method on *Session too so it could still call AddressTranslator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this is meant to be used for unit testing implementations of policies and other gocql public interfaces I don't think users will be using it with a session so I don't think it's necessary to involve the address translator. Maybe we can consider it if we get requests for it in the future?

@joao-r-reis joao-r-reis force-pushed the cassgo71-hostfilter-testable branch 2 times, most recently from fcc8b35 to ebe9a0d Compare June 17, 2025 15:21
It is not possible to test implementations of public gocql interfaces such as
HostFilter because it requires creating HostInfo objects (HostInfo has private fields).

With this change, it is now possible to create HostInfo objects from system.local / system.peers rows
using NewTestHostInfoFromRow().

Patch by João Reis; reviewed by James Hartig for CASSGO-71
@joao-r-reis joao-r-reis force-pushed the cassgo71-hostfilter-testable branch from ebe9a0d to 8b51c53 Compare June 17, 2025 15:34
@joao-r-reis joao-r-reis merged commit be35a5b into apache:trunk Jun 17, 2025
72 checks passed
@joao-r-reis joao-r-reis deleted the cassgo71-hostfilter-testable branch June 17, 2025 15:48
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.

2 participants