@@ -59,6 +59,8 @@ import (
5959)
6060
6161const podCreationTimeout = 10 * time .Minute
62+ const portReadinessTimeout = 1 * time .Minute
63+ const k8sQueryTimeout = 1 * time .Minute
6264
6365type featureFlag struct {
6466 Name string
@@ -593,6 +595,48 @@ func waitForRabbitmqRunningWithOffset(cluster *rabbitmqv1beta1.RabbitmqCluster,
593595 ExpectWithOffset (callStackOffset , err ).NotTo (HaveOccurred ())
594596}
595597
598+ func waitForPortConnectivity (cluster * rabbitmqv1beta1.RabbitmqCluster ) {
599+ waitForPortConnectivityWithOffset (cluster , 2 )
600+ }
601+ func waitForPortConnectivityWithOffset (cluster * rabbitmqv1beta1.RabbitmqCluster , callStackOffset int ) {
602+ EventuallyWithOffset (callStackOffset , func () error {
603+ _ , err := kubectlExec (cluster .Namespace , statefulSetPodName (cluster , 0 ), "rabbitmq" ,
604+ "rabbitmq-diagnostics" , "check_port_connectivity" )
605+ return err
606+ }, portReadinessTimeout , 3 ).Should (Not (HaveOccurred ()))
607+ }
608+
609+ func waitForPortReadiness (cluster * rabbitmqv1beta1.RabbitmqCluster , port int ) {
610+ waitForPortReadinessWithOffset (cluster , port , 2 )
611+ }
612+ func waitForPortReadinessWithOffset (cluster * rabbitmqv1beta1.RabbitmqCluster , port int , callStackOffset int ) {
613+ EventuallyWithOffset (callStackOffset , func () error {
614+ _ , err := kubectlExec (cluster .Namespace , statefulSetPodName (cluster , 0 ), "rabbitmq" ,
615+ "rabbitmq-diagnostics" , "check_port_listener" , strconv .Itoa (port ))
616+ return err
617+ }, portReadinessTimeout , 3 ).Should (Not (HaveOccurred ()))
618+ }
619+
620+ func hasFeatureEnabled (cluster * rabbitmqv1beta1.RabbitmqCluster , featureFlagName string ) bool {
621+ output , err := kubectlExec (cluster .Namespace ,
622+ statefulSetPodName (cluster , 0 ),
623+ "rabbitmq" ,
624+ "rabbitmqctl" ,
625+ "list_feature_flags" ,
626+ "--formatter=json" ,
627+ )
628+ Expect (err ).NotTo (HaveOccurred ())
629+ var flags []featureFlag
630+ Expect (json .Unmarshal (output , & flags )).To (Succeed ())
631+
632+ for _ , v := range flags {
633+ if v .Name == featureFlagName && v .State == "enabled" {
634+ return true
635+ }
636+ }
637+ return false
638+ }
639+
596640// asserts an event with reason: "TLSError", occurs for the cluster in it's namespace
597641func assertTLSError (cluster * rabbitmqv1beta1.RabbitmqCluster ) {
598642 var err error
@@ -839,15 +883,17 @@ func publishAndConsumeMQTTMsg(hostname, port, username, password string, overWeb
839883 EventuallyWithOffset (1 , func () bool {
840884 token = c .Connect ()
841885 // Waits for the network request to reach the destination and receive a response
842- if ! token .WaitTimeout (3 * time .Second ) {
886+ if ! token .WaitTimeout (30 * time .Second ) {
887+ fmt .Printf ("Timed out\n " )
843888 return false
844889 }
845890
846891 if err := token .Error (); err == nil {
892+ fmt .Printf ("Connected !\n " )
847893 return true
848894 }
849895 return false
850- }, 30 , 2 ).Should (BeTrue (), "Expected to be able to connect to MQTT port" )
896+ }, 30 , 20 ).Should (BeTrue (), "Expected to be able to connect to MQTT port" )
851897
852898 topic := "tests/mqtt"
853899 msgReceived := false
@@ -948,16 +994,26 @@ func publishAndConsumeStreamMsg(host, port, username, password string) {
948994 portInt , err := strconv .Atoi (port )
949995 Expect (err ).ToNot (HaveOccurred ())
950996
951- env , err := stream .NewEnvironment (stream .NewEnvironmentOptions ().
952- SetHost (host ).
953- SetPort (portInt ).
954- SetPassword (password ).
955- SetUser (username ).
956- SetAddressResolver (stream.AddressResolver {
957- Host : host ,
958- Port : portInt ,
959- }))
960- Expect (err ).ToNot (HaveOccurred ())
997+ var env * stream.Environment
998+ Eventually (func () error {
999+ fmt .Println ("connecting to stream endpoint ..." )
1000+ env , err = stream .NewEnvironment (stream .NewEnvironmentOptions ().
1001+ SetHost (host ).
1002+ SetPort (portInt ).
1003+ SetPassword (password ).
1004+ SetUser (username ).
1005+ SetAddressResolver (stream.AddressResolver {
1006+ Host : host ,
1007+ Port : portInt ,
1008+ }))
1009+ if err == nil {
1010+ fmt .Println ("connected to stream endpoint" )
1011+ return nil
1012+ } else {
1013+ fmt .Printf ("failed to connect to stream endpoint (%s:%d) due to %g\n " , host , portInt , err )
1014+ }
1015+ return err
1016+ }, portReadinessTimeout * 5 , portReadinessTimeout ).ShouldNot (HaveOccurred ())
9611017
9621018 const streamName = "system-test-stream"
9631019 Expect (env .DeclareStream (
0 commit comments