MCPcopy Create free account
hub / github.com/datastax/cql-proxy / TestProxy_Compression

Function TestProxy_Compression

proxy/proxy_test.go:344–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

342}
343
344func TestProxy_Compression(t *testing.T) {
345 ctx, cancel := context.WithCancel(context.Background())
346 tester, proxyContactPoint, err := setupProxyTest(ctx, 1, nil)
347 defer func() {
348 cancel()
349 tester.shutdown()
350 }()
351 require.NoError(t, err)
352 tests := []struct {
353 compressor gocql.Compressor
354 }{
355 {
356 compressor: gocql.SnappyCompressor{},
357 },
358 {
359 compressor: lz4Compressor{},
360 },
361 }
362
363 for _, tt := range tests {
364 t.Run(tt.compressor.Name(), func(t *testing.T) {
365 config := gocql.NewCluster(proxyContactPoint)
366 config.Authenticator = &gocql.PasswordAuthenticator{Username: "cassandra", Password: "cassandra"}
367 config.Compressor = tt.compressor
368
369 var sess *gocql.Session
370 require.True(t, waitUntil(5*time.Second, func() bool {
371 var err error
372 sess, err = config.CreateSession()
373 return err == nil && sess != nil
374 }), "failed to create session")
375 defer sess.Close()
376
377 assert.True(t, waitUntil(5*time.Second, func() bool {
378 var err error
379 err = sess.Query("select * from test").Iter().Close()
380 return err == nil
381 }), "failed to execute query")
382 })
383 }
384}
385
386func queryTestHosts(ctx context.Context, cl *proxycore.ClientConn) (map[string]struct{}, error) {
387 hosts := make(map[string]struct{})

Callers

nothing calls this directly

Calls 6

setupProxyTestFunction · 0.85
shutdownMethod · 0.80
NameMethod · 0.80
QueryMethod · 0.80
waitUntilFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected