initializeTLSCluster initializes the TLS cluster for testing
(ctx context.Context)
| 451 | |
| 452 | // initializeTLSCluster initializes the TLS cluster for testing |
| 453 | func 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 |
| 490 | func cleanupTLSCluster() { |
no test coverage detected