From 5ada9e215cac14ebdfcccae53f94088a1a399873 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Tue, 13 Aug 2024 13:26:24 +0000 Subject: [PATCH] test: get smb server external ip fix fix fix fix fix --- test/e2e/suite_test.go | 19 +++++++++++++++++++ test/utils/get_smb_svc_public_ip.sh | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/utils/get_smb_svc_public_ip.sh diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 50eba0bf646..d54b6fab8ba 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -161,6 +161,25 @@ var _ = ginkgo.BeforeSuite(func() { err := os.Chdir("test/e2e") gomega.Expect(err).NotTo(gomega.HaveOccurred()) }() + + getSMBPublicIPScript := "test/utils/get_smb_svc_public_ip.sh" + log.Printf("run script: %s\n", getSMBPublicIPScript) + + cmd := exec.Command("bash", getSMBPublicIPScript) + output, err := cmd.CombinedOutput() + log.Printf("got output: %v, error: %v\n", string(output), err) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + smbPublicIP := strings.TrimSuffix(string(output), "\n") + source := fmt.Sprintf("//%s/share", smbPublicIP) + + log.Printf("use source on Windows: %v\n", source) + defaultStorageClassParameters["source"] = source + retainStorageClassParameters["source"] = source + archiveStorageClassParameters["source"] = source + archiveSubDirStorageClassParameters["source"] = source + subDirStorageClassParameters["source"] = source + noProvisionerSecretStorageClassParameters["source"] = source } }) diff --git a/test/utils/get_smb_svc_public_ip.sh b/test/utils/get_smb_svc_public_ip.sh new file mode 100644 index 00000000000..dcf1c91cacd --- /dev/null +++ b/test/utils/get_smb_svc_public_ip.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Copyright 2020 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +kubectl get svc smb-server -n default | grep smb | awk '{print $4}'