diff --git a/test/e2e/dynamic_provisioning_test.go b/test/e2e/dynamic_provisioning_test.go index 96ef33dadf9..d495b76d6d8 100644 --- a/test/e2e/dynamic_provisioning_test.go +++ b/test/e2e/dynamic_provisioning_test.go @@ -19,6 +19,7 @@ package e2e import ( "fmt" "log" + "os" "os/exec" "strings" @@ -57,8 +58,17 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { ns = f.Namespace if isUsingHostProcessDeployment { - log.Printf("trying to get smb-server service IP address since it's using host process deployment...") - cmd := exec.Command("kubectl", "get svc smb-server | grep smb | awk '{print $4}'") + err := os.Chdir("../..") + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + defer 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()) 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..33a7751f777 --- /dev/null +++ b/test/utils/get_smb_svc_public_ip.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Copyright 2023 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 | grep smb | awk '{print $4}' +