MCPcopy
hub / github.com/redis/go-redis / initializeTLSCluster

Function initializeTLSCluster

main_test.go:453–487  ·  view source on GitHub ↗

initializeTLSCluster initializes the TLS cluster for testing

(ctx context.Context)

Source from the content-addressed store, hash-verified

451
452// initializeTLSCluster initializes the TLS cluster for testing
453func initializeTLSCluster(ctx context.Context) error {
454 // Load TLS config
455 certDir := "dockers/osscluster-tls/tls"
456 _, err := loadClusterTLSConfig(certDir)
457 if err != nil {
458 return fmt.Errorf("failed to load TLS config: %w", err)
459 }
460
461 // The TLS cluster is auto-created by the container (REDIS_CLUSTER=yes)
462 // Just verify it's ready by checking cluster info
463 client := redis.NewClient(&redis.Options{
464 Addr: net.JoinHostPort("127.0.0.1", tlsCluster.ports[0]),
465 TLSConfig: &tls.Config{
466 InsecureSkipVerify: true,
467 },
468 })
469 defer client.Close()
470
471 // Wait for cluster to be ready
472 err = eventually(func() error {
473 info, err := client.ClusterInfo(ctx).Result()
474 if err != nil {
475 return fmt.Errorf("failed to get cluster info: %w", err)
476 }
477 if !strings.Contains(info, "cluster_state:ok") {
478 return fmt.Errorf("cluster not ready: %s", info)
479 }
480 return nil
481 }, 30*time.Second)
482 if err != nil {
483 return fmt.Errorf("TLS cluster not ready: %w", err)
484 }
485
486 return nil
487}
488
489// cleanupTLSCluster cleans up TLS cluster resources
490func cleanupTLSCluster() {

Callers 1

main_test.goFile · 0.85

Calls 6

loadClusterTLSConfigFunction · 0.85
eventuallyFunction · 0.85
CloseMethod · 0.65
ResultMethod · 0.65
ClusterInfoMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected