@@ -23,6 +23,7 @@ import (
2323 "testing"
2424 "time"
2525
26+ "github.com/Masterminds/semver/v3"
2627 "github.com/stretchr/testify/assert"
2728 "github.com/stretchr/testify/require"
2829 core_v1 "k8s.io/api/core/v1"
@@ -46,14 +47,18 @@ const (
4647 ClusterRoles
4748 ClusterRoleBindings
4849
49- numHAPods = 16
50- numNonHAPods = 6
50+ numHAPodsWithScheduler = 16
51+ numHAPodsOld = 13
52+ numNonHAPodsWithScheduler = 6
53+ numNonHAPodsOld = 5
5154
5255 thirdPartyDevNamespace = "default"
5356 devRedisReleaseName = "dapr-dev-redis"
5457 devZipkinReleaseName = "dapr-dev-zipkin"
5558)
5659
60+ var VersionWithScheduler = semver .MustParse ("1.14.0" )
61+
5762type VersionDetails struct {
5863 RuntimeVersion string
5964 DashboardVersion string
@@ -131,7 +136,7 @@ func UpgradeTest(details VersionDetails, opts TestOptions) func(t *testing.T) {
131136 done := make (chan struct {})
132137 podsRunning := make (chan struct {})
133138
134- go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning )
139+ go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning , details )
135140 select {
136141 case <- podsRunning :
137142 t .Logf ("verified all pods running in namespace %s are running after upgrade" , DaprTestNamespace )
@@ -544,7 +549,7 @@ func GenerateNewCertAndRenew(details VersionDetails, opts TestOptions) func(t *t
544549 done := make (chan struct {})
545550 podsRunning := make (chan struct {})
546551
547- go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning )
552+ go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning , details )
548553 select {
549554 case <- podsRunning :
550555 t .Logf ("verified all pods running in namespace %s are running after certficate change" , DaprTestNamespace )
@@ -575,7 +580,7 @@ func UseProvidedPrivateKeyAndRenewCerts(details VersionDetails, opts TestOptions
575580 done := make (chan struct {})
576581 podsRunning := make (chan struct {})
577582
578- go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning )
583+ go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning , details )
579584 select {
580585 case <- podsRunning :
581586 t .Logf ("verified all pods running in namespace %s are running after certficate change" , DaprTestNamespace )
@@ -608,7 +613,7 @@ func UseProvidedNewCertAndRenew(details VersionDetails, opts TestOptions) func(t
608613 done := make (chan struct {})
609614 podsRunning := make (chan struct {})
610615
611- go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning )
616+ go waitAllPodsRunning (t , DaprTestNamespace , opts .HAEnabled , done , podsRunning , details )
612617 select {
613618 case <- podsRunning :
614619 t .Logf ("verified all pods running in namespace %s are running after certficate change" , DaprTestNamespace )
@@ -1164,7 +1169,7 @@ func waitPodDeletion(t *testing.T, done, podsDeleted chan struct{}) {
11641169 }
11651170}
11661171
1167- func waitAllPodsRunning (t * testing.T , namespace string , haEnabled bool , done , podsRunning chan struct {}) {
1172+ func waitAllPodsRunning (t * testing.T , namespace string , haEnabled bool , done , podsRunning chan struct {}, details VersionDetails ) {
11681173 for {
11691174 select {
11701175 case <- done : // if timeout was reached.
@@ -1198,14 +1203,48 @@ func waitAllPodsRunning(t *testing.T, namespace string, haEnabled bool, done, po
11981203 }
11991204 }
12001205 }
1201- if len (list .Items ) == countOfReadyPods && ((haEnabled && countOfReadyPods == numHAPods ) || (! haEnabled && countOfReadyPods == numNonHAPods )) {
1206+ pods , err := getVersionedNumberOfPods (haEnabled , details )
1207+ if err != nil {
1208+ t .Error (err )
1209+ }
1210+ if len (list .Items ) == countOfReadyPods && ((haEnabled && countOfReadyPods == pods ) || (! haEnabled && countOfReadyPods == pods )) {
12021211 podsRunning <- struct {}{}
12031212 }
12041213
12051214 time .Sleep (15 * time .Second )
12061215 }
12071216}
12081217
1218+ func getVersionedNumberOfPods (isHAEnabled bool , details VersionDetails ) (int , error ) {
1219+ if isHAEnabled {
1220+ if details .UseDaprLatestVersion {
1221+ return numHAPodsWithScheduler , nil
1222+ }
1223+ rv , err := semver .NewVersion (details .RuntimeVersion )
1224+ if err != nil {
1225+ return 0 , err
1226+ }
1227+
1228+ if rv .LessThan (VersionWithScheduler ) {
1229+ return numHAPodsOld , nil
1230+ }
1231+ return numHAPodsWithScheduler , nil
1232+ } else {
1233+ if details .UseDaprLatestVersion {
1234+ return numNonHAPodsWithScheduler , nil
1235+ }
1236+ rv , err := semver .NewVersion (details .RuntimeVersion )
1237+ if err != nil {
1238+ return 0 , err
1239+ }
1240+
1241+ if rv .LessThan (VersionWithScheduler ) {
1242+ return numNonHAPodsOld , nil
1243+ }
1244+ return numNonHAPodsWithScheduler , nil
1245+ }
1246+ }
1247+
12091248func exportCurrentCertificate (daprPath string ) error {
12101249 _ , err := os .Stat ("./certs" )
12111250 if err != nil {
0 commit comments