Skip to content

Commit

Permalink
Merge pull request #347 from eliyamlevy/release/v3.0
Browse files Browse the repository at this point in the history
Fixed helper func to grab version from env
  • Loading branch information
eliyamlevy authored May 1, 2023
2 parents 255b154 + 6f26e14 commit 5899971
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
7 changes: 2 additions & 5 deletions scripts/hull
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ cd $(dirname $0)/..

cd tests
echo "Running Hull Tests"
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
go test -timeout 30s -run ^TestChart$ github.com/rancher/backup-restore-operator/tests/hull -helm_version=$HELM_VERSION
else
go test -timeout 30s -run ^TestChart$ github.com/rancher/backup-restore-operator/tests/hull -helm_version=$HELM_VERSION_DEV
fi

go test -timeout 30s -run ^TestChart$ github.com/rancher/backup-restore-operator/tests/hull

cd ..
4 changes: 4 additions & 0 deletions scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ if echo $TAG | grep -q dirty; then
HELM_TAG=$HELM_TAG_DEV
HELM_VERSION=$HELM_VERSION_DEV
fi

export GIT_TAG=$GIT_TAG
export HELM_VERSION_DEV=$HELM_VERSION_DEV
export HELM_VERSION=$HELM_VERSION
16 changes: 6 additions & 10 deletions tests/hull/helper.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package hull

import (
"flag"
)
import "os"

var helm_version string

func GetChartFileNameWithVersion() string {
flag.StringVar(&helm_version, "helm_version", "", "Helm Chart Version")
if helm_version == "" {
helm_version = "0.0.0-dev"
func GetChartVersionFromEnv() string {
if os.Getenv("GIT_TAG") != "" {
return "rancher-backup-" + os.Getenv("HELM_VERSION") + ".tgz"
} else {
return "rancher-backup-" + os.Getenv("HELM_VERSION_DEV") + ".tgz"
}
return "rancher-backup-" + helm_version + ".tgz"
}
7 changes: 1 addition & 6 deletions tests/hull/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var ChartPath = utils.MustGetPathFromModuleRoot("..", "dist", "artifacts", GetChartFileNameWithVersion())
var ChartPath = utils.MustGetPathFromModuleRoot("..", "dist", "artifacts", GetChartVersionFromEnv())

var (
DefaultReleaseName = "rancher-backup"
Expand Down Expand Up @@ -294,7 +294,6 @@ var suite = test.Suite{
debug := checker.MustRenderValue[bool](tc, ".Values.debug")
trace := checker.MustRenderValue[bool](tc, ".Values.trace")
for _, container := range podTemplateSpec.Spec.Containers {
tc.T.Logf("%v", container.Args)
if (trace) && (debug) {
assert.Contains(tc.T, container.Args, "--debug",
"expected container %s in %T %s to have --debug arg",
Expand Down Expand Up @@ -352,7 +351,6 @@ var suite = test.Suite{
return
}
ipp := checker.MustRenderValue[corev1.PullPolicy](tc, ".Values.imagePullPolicy")
tc.T.Logf("%v", ipp)
for _, container := range podTemplateSpec.Spec.Containers {
assert.Equal(tc.T, container.ImagePullPolicy, ipp,
"expected container %s in %T %s to have no args",
Expand Down Expand Up @@ -453,7 +451,6 @@ var suite = test.Suite{
endpointCA := checker.MustRenderValue[string](tc, ".Values.s3.endpointCA")
folder := checker.MustRenderValue[string](tc, ".Values.s3.folder")
insecureTLSSkipVerify := strconv.FormatBool(checker.MustRenderValue[bool](tc, ".Values.s3.insecureTLSSkipVerify"))
// tc.T.Logf("%v", insecureTLSSkipVerify)
region := checker.MustRenderValue[string](tc, ".Values.s3.region")
if s3Enabled {
assert.Equal(tc.T, bucketName, secret.StringData["bucketName"], "S3 Secret Improperly configured (bucketName)")
Expand Down Expand Up @@ -627,7 +624,6 @@ var suite = test.Suite{
if checker.Select("rancher-backup-patch-sa", "cattle-resources-system", obj) || proxy == "" {
return
}
tc.T.Logf("proxy:%s, noProxy:%s", proxy, noProxy)
envVar := []corev1.EnvVar([]corev1.EnvVar{
corev1.EnvVar{
Name: "CHART_NAMESPACE",
Expand Down Expand Up @@ -669,7 +665,6 @@ var suite = test.Suite{
return
}
imagePullSecrets, _ := checker.RenderValue[[]corev1.LocalObjectReference](tc, ".Values.imagePullSecrets")
tc.T.Logf("ips: %v", imagePullSecrets)
if len(imagePullSecrets) > 0 {
assert.Equal(tc.T, imagePullSecrets, podTemplateSpec.Spec.ImagePullSecrets, "ImagePullSecrets in Deployment %s/%s do not have correct configuration", obj.GetNamespace(), obj.GetName())
}
Expand Down
2 changes: 2 additions & 0 deletions tests/hull/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/rancher/hull/pkg/test"
)

// var HelmVersion = flag.String("helm_version", "", "Helm Chart Version")

func TestChart(t *testing.T) {
flag.Parse()
opts := test.GetRancherOptions()
Expand Down

0 comments on commit 5899971

Please sign in to comment.