| 342 | } |
| 343 | |
| 344 | func 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 | |
| 386 | func queryTestHosts(ctx context.Context, cl *proxycore.ClientConn) (map[string]struct{}, error) { |
| 387 | hosts := make(map[string]struct{}) |