@@ -50,12 +50,13 @@ const (
5050)
5151
5252type VersionDetails struct {
53- RuntimeVersion string
54- DashboardVersion string
55- ImageVariant string
56- CustomResourceDefs []string
57- ClusterRoles []string
58- ClusterRoleBindings []string
53+ RuntimeVersion string
54+ DashboardVersion string
55+ ImageVariant string
56+ CustomResourceDefs []string
57+ ClusterRoles []string
58+ ClusterRoleBindings []string
59+ UseDaprLatestVersion bool
5960}
6061
6162type TestOptions struct {
@@ -71,20 +72,26 @@ type TestCase struct {
7172 Callable func (* testing.T )
7273}
7374
74- // GetVersionsFromEnv will return values from required environment variables,
75+ // GetVersionsFromEnv will return values from required environment variables.
76+ // parameter `latest` is used to determine if the latest versions of dapr & dashboard should be used.
7577// if environment variables are not set it fails the test.
76- func GetVersionsFromEnv (t * testing.T ) (string , string ) {
78+ func GetVersionsFromEnv (t * testing.T , latest bool ) (string , string ) {
7779 var daprRuntimeVersion , daprDashboardVersion string
78-
79- if runtimeVersion , ok := os .LookupEnv ("DAPR_RUNTIME_VERSION" ); ok {
80+ runtimeEnvVar := "DAPR_RUNTIME_PINNED_VERSION"
81+ dashboardEnvVar := "DAPR_DASHBOARD_PINNED_VERSION"
82+ if latest {
83+ runtimeEnvVar = "DAPR_RUNTIME_LATEST_VERSION"
84+ dashboardEnvVar = "DAPR_DASHBOARD_LATEST_VERSION"
85+ }
86+ if runtimeVersion , ok := os .LookupEnv (runtimeEnvVar ); ok {
8087 daprRuntimeVersion = runtimeVersion
8188 } else {
82- t .Fatalf ("env var \" DAPR_RUNTIME_VERSION \" not set" )
89+ t .Fatalf ("env var \" %s \" not set" , runtimeEnvVar )
8390 }
84- if dashboardVersion , ok := os .LookupEnv ("DAPR_DASHBOARD_VERSION" ); ok {
91+ if dashboardVersion , ok := os .LookupEnv (dashboardEnvVar ); ok {
8592 daprDashboardVersion = dashboardVersion
8693 } else {
87- t .Fatalf ("env var \" DAPR_DASHBOARD_VERSION \" not set" )
94+ t .Fatalf ("env var \" %s \" not set" , dashboardEnvVar )
8895 }
8996 return daprRuntimeVersion , daprDashboardVersion
9097}
@@ -182,6 +189,27 @@ func GetTestsOnUninstall(details VersionDetails, opts TestOptions) []TestCase {
182189 }
183190}
184191
192+ func GetTestForCertRenewal (currentVersionDetails VersionDetails , installOpts TestOptions ) []TestCase {
193+ tests := []TestCase {}
194+ tests = append (tests , []TestCase {
195+ {"Renew certificate which expires in less than 30 days" , GenerateNewCertAndRenew (currentVersionDetails , installOpts )},
196+ }... )
197+ tests = append (tests , GetTestsPostCertificateRenewal (currentVersionDetails , installOpts )... )
198+ tests = append (tests , []TestCase {
199+ {"Cert Expiry warning message check " + currentVersionDetails .RuntimeVersion , CheckMTLSStatus (currentVersionDetails , installOpts , true )},
200+ }... )
201+
202+ // tests for certificate renewal with provided certificates.
203+ tests = append (tests , []TestCase {
204+ {"Renew certificate which expires in after 30 days" , UseProvidedNewCertAndRenew (currentVersionDetails , installOpts )},
205+ }... )
206+ tests = append (tests , GetTestsPostCertificateRenewal (currentVersionDetails , installOpts )... )
207+ tests = append (tests , []TestCase {
208+ {"Cert Expiry no warning message check " + currentVersionDetails .RuntimeVersion , CheckMTLSStatus (currentVersionDetails , installOpts , false )},
209+ }... )
210+ return tests
211+ }
212+
185213func GetTestsPostCertificateRenewal (details VersionDetails , opts TestOptions ) []TestCase {
186214 return []TestCase {
187215 {"crds exist " + details .RuntimeVersion , CRDTest (details , opts )},
@@ -475,6 +503,9 @@ func UseProvidedPrivateKeyAndRenewCerts(details VersionDetails, opts TestOptions
475503 "--private-key" , "../testdata/example-root.key" ,
476504 "--valid-until" , "20" ,
477505 }
506+ if details .ImageVariant != "" {
507+ args = append (args , "--image-variant" , details .ImageVariant )
508+ }
478509 output , err := spawn .Command (daprPath , args ... )
479510 t .Log (output )
480511 require .NoError (t , err , "expected no error on certificate renewal" )
@@ -505,6 +536,9 @@ func UseProvidedNewCertAndRenew(details VersionDetails, opts TestOptions) func(t
505536 "--issuer-public-certificate" , "./certs/issuer.crt" ,
506537 "--restart" ,
507538 }
539+ if details .ImageVariant != "" {
540+ args = append (args , "--image-variant" , details .ImageVariant )
541+ }
508542 output , err := spawn .Command (daprPath , args ... )
509543 t .Log (output )
510544 require .NoError (t , err , "expected no error on certificate renewal" )
@@ -671,9 +705,11 @@ func installTest(details VersionDetails, opts TestOptions) func(t *testing.T) {
671705 "init" , "-k" ,
672706 "--wait" ,
673707 "-n" , DaprTestNamespace ,
674- "--runtime-version" , details .RuntimeVersion ,
675708 "--log-as-json" ,
676709 }
710+ if ! details .UseDaprLatestVersion {
711+ args = append (args , "--runtime-version" , details .RuntimeVersion )
712+ }
677713 if opts .HAEnabled {
678714 args = append (args , "--enable-ha" )
679715 }
0 commit comments