Skip to content

Commit 0266e7c

Browse files
committed
Fix and add Astra endpoint test for region
1 parent 7b8eb3f commit 0266e7c

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

astra/endpoint_test.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,17 @@ func TestAstraResolver_NewEndpoint(t *testing.T) {
7979
Index: 0,
8080
Type: datatype.Uuid,
8181
},
82+
{
83+
Keyspace: "system",
84+
Table: "peers",
85+
Name: "data_center",
86+
Index: 1,
87+
Type: datatype.Varchar,
88+
},
8289
},
8390
},
8491
Data: message.RowSet{
85-
message.Row{makeUUID(hostId)},
92+
message.Row{makeUUID(hostId), makeVarchar("us-east1")},
8693
},
8794
}, primitive.ProtocolVersion4)
8895

@@ -92,6 +99,43 @@ func TestAstraResolver_NewEndpoint(t *testing.T) {
9299
assert.Contains(t, endpoint.Key(), hostId)
93100
}
94101

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+
95139
func TestAstraResolver_NewEndpointInvalidHostID(t *testing.T) {
96140
resolver := createResolver(t)
97141
_, err := resolver.Resolve()
@@ -229,3 +273,8 @@ func makeUUID(uuid string) []byte {
229273
bytes, _ := proxycore.EncodeType(datatype.Uuid, primitive.ProtocolVersion4, parsedUuid)
230274
return bytes
231275
}
276+
277+
func makeVarchar(s string) []byte {
278+
bytes, _ := proxycore.EncodeType(datatype.Varchar, primitive.ProtocolVersion4, s)
279+
return bytes
280+
}

0 commit comments

Comments
 (0)