@@ -79,10 +79,17 @@ func TestAstraResolver_NewEndpoint(t *testing.T) {
79
79
Index : 0 ,
80
80
Type : datatype .Uuid ,
81
81
},
82
+ {
83
+ Keyspace : "system" ,
84
+ Table : "peers" ,
85
+ Name : "data_center" ,
86
+ Index : 1 ,
87
+ Type : datatype .Varchar ,
88
+ },
82
89
},
83
90
},
84
91
Data : message.RowSet {
85
- message.Row {makeUUID (hostId )},
92
+ message.Row {makeUUID (hostId ), makeVarchar ( "us-east1" ) },
86
93
},
87
94
}, primitive .ProtocolVersion4 )
88
95
@@ -92,6 +99,43 @@ func TestAstraResolver_NewEndpoint(t *testing.T) {
92
99
assert .Contains (t , endpoint .Key (), hostId )
93
100
}
94
101
102
+ func TestAstraResolver_NewEndpoint_Ignored (t * testing.T ) {
103
+ resolver := createResolver (t )
104
+ _ , err := resolver .Resolve ()
105
+ require .NoError (t , err )
106
+
107
+ const hostId = "a2e24181-d732-402a-ab06-894a8b2f6094"
108
+
109
+ rs := proxycore .NewResultSet (& message.RowsResult {
110
+ Metadata : & message.RowsMetadata {
111
+ ColumnCount : 1 ,
112
+ Columns : []* message.ColumnMetadata {
113
+ {
114
+ Keyspace : "system" ,
115
+ Table : "peers" ,
116
+ Name : "host_id" ,
117
+ Index : 0 ,
118
+ Type : datatype .Uuid ,
119
+ },
120
+ {
121
+ Keyspace : "system" ,
122
+ Table : "peers" ,
123
+ Name : "data_center" ,
124
+ Index : 1 ,
125
+ Type : datatype .Varchar ,
126
+ },
127
+ },
128
+ },
129
+ Data : message.RowSet {
130
+ message.Row {makeUUID (hostId ), makeVarchar ("ignored" )},
131
+ },
132
+ }, primitive .ProtocolVersion4 )
133
+
134
+ endpoint , err := resolver .NewEndpoint (rs .Row (0 ))
135
+ assert .Nil (t , endpoint )
136
+ assert .ErrorIs (t , err , proxycore .IgnoreEndpoint )
137
+ }
138
+
95
139
func TestAstraResolver_NewEndpointInvalidHostID (t * testing.T ) {
96
140
resolver := createResolver (t )
97
141
_ , err := resolver .Resolve ()
@@ -229,3 +273,8 @@ func makeUUID(uuid string) []byte {
229
273
bytes , _ := proxycore .EncodeType (datatype .Uuid , primitive .ProtocolVersion4 , parsedUuid )
230
274
return bytes
231
275
}
276
+
277
+ func makeVarchar (s string ) []byte {
278
+ bytes , _ := proxycore .EncodeType (datatype .Varchar , primitive .ProtocolVersion4 , s )
279
+ return bytes
280
+ }
0 commit comments