@@ -2,6 +2,7 @@ package e2eupgrade
2
2
3
3
import (
4
4
"fmt"
5
+ "os"
5
6
"os/exec"
6
7
"testing"
7
8
@@ -33,6 +34,8 @@ func TestZeroDowntimeUpgradeAfterOperatorUpgrade(t *testing.T) {
33
34
// Get the upgrade version from environment
34
35
upgradeVersion := GetKubeRayUpgradeVersion ()
35
36
37
+ test .T ().Logf ("Detected upgrade version: %s" , upgradeVersion )
38
+
36
39
// Create RayService custom resource
37
40
rayServiceAC := rayv1ac .RayService (rayServiceName , namespace .Name ).WithSpec (e2e .RayServiceSampleYamlApplyConfiguration ())
38
41
rayService , err := test .Client ().Ray ().RayV1 ().RayServices (namespace .Name ).Apply (test .Ctx (), rayServiceAC , TestApplyOptions )
@@ -76,15 +79,38 @@ func TestZeroDowntimeUpgradeAfterOperatorUpgrade(t *testing.T) {
76
79
g .Expect (endpoints .Subsets [0 ].Addresses ).To (HaveLen (1 ))
77
80
78
81
// Upgrade KubeRay operator to latest version and replace CRDs
79
- test .T ().Logf ("Upgrading the KubeRay operator to the latest release" )
80
- cmd := exec .Command ("kubectl" , "replace" , "-k" , fmt .Sprintf ("github.com/ray-project/kuberay/ray-operator/config/crd?ref=%s" , upgradeVersion )) //nolint:gosec // required for upgrade
81
- err = cmd .Run ()
82
- g .Expect (err ).NotTo (HaveOccurred ())
83
- g .Eventually (cmd , TestTimeoutShort ).Should (WithTransform (ProcessStateSuccess , BeTrue ()))
84
- cmd = exec .Command ("helm" , "upgrade" , "kuberay-operator" , "kuberay/kuberay-operator" , "--version" , upgradeVersion )
85
- err = cmd .Run ()
86
- g .Expect (err ).NotTo (HaveOccurred ())
87
- g .Eventually (cmd , TestTimeoutShort ).Should (WithTransform (ProcessStateSuccess , BeTrue ()))
82
+ test .T ().Logf ("Upgrading the KubeRay operator to %s" , upgradeVersion )
83
+
84
+ useLocalHelmChart := false
85
+
86
+ if val , ok := os .LookupEnv ("USE_LOCAL_HELM_CHART" ); ok && val == "true" {
87
+ useLocalHelmChart = true
88
+ }
89
+
90
+ if useLocalHelmChart {
91
+ cmd := exec .Command ("kubectl" , "replace" , "-k" , "../../config/crd" )
92
+ output , err := cmd .CombinedOutput ()
93
+ if err != nil {
94
+ test .T ().Logf ("Error upgrading KubeRay operator: %v\n Command output:\n %s" , err , string (output ))
95
+ t .Fatal ("Failed to upgrade KubeRay operator" )
96
+ }
97
+ g .Eventually (cmd , TestTimeoutShort ).Should (WithTransform (ProcessStateSuccess , BeTrue ()))
98
+
99
+ t .Logf ("Upgrading operator deployment using local helm image version: %s" , upgradeVersion )
100
+ cmd = exec .Command ("helm" , "upgrade" , "kuberay-operator" , "../../../helm-chart/kuberay-operator" , "--set" , fmt .Sprintf ("image.repository=kuberay/kuberay-operator,image.tag=%s" , upgradeVersion )) //nolint:gosec // required for upgrade
101
+ err = cmd .Run ()
102
+ g .Expect (err ).NotTo (HaveOccurred ())
103
+ g .Eventually (cmd , TestTimeoutShort ).Should (WithTransform (ProcessStateSuccess , BeTrue ()))
104
+ } else {
105
+ cmd := exec .Command ("kubectl" , "replace" , "-k" , fmt .Sprintf ("github.com/ray-project/kuberay/ray-operator/config/crd?ref=%s" , upgradeVersion )) //nolint:gosec // required for upgrade
106
+ err = cmd .Run ()
107
+ g .Expect (err ).NotTo (HaveOccurred ())
108
+ g .Eventually (cmd , TestTimeoutShort ).Should (WithTransform (ProcessStateSuccess , BeTrue ()))
109
+ cmd = exec .Command ("helm" , "upgrade" , "kuberay-operator" , "kuberay/kuberay-operator" , "--version" , upgradeVersion )
110
+ err = cmd .Run ()
111
+ g .Expect (err ).NotTo (HaveOccurred ())
112
+ g .Eventually (cmd , TestTimeoutShort ).Should (WithTransform (ProcessStateSuccess , BeTrue ()))
113
+ }
88
114
89
115
// Validate RayService is able to serve requests during the upgrade
90
116
test .T ().Logf ("Sending requests to the RayService to make sure it is ready to serve requests" )
0 commit comments