Skip to content

Commit

Permalink
Merge pull request #689 from kubernetes-sigs/on-prem-win-test
Browse files Browse the repository at this point in the history
test: add e2e test for on-prem server support on Windows
  • Loading branch information
andyzhangx authored Jun 1, 2021
2 parents a3f189f + e08a80b commit 7d52167
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {

ginkgo.It("should mount on-prem smb server [file.csi.azure.com]", func() {
skipIfUsingInTreeVolumePlugin()
skipIfTestingInWindowsCluster()

secretName := "smbcreds"
ginkgo.By(fmt.Sprintf("creating secret %s in namespace %s", secretName, ns.Name))
Expand All @@ -931,6 +930,27 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
tsecret.Create()
defer tsecret.Cleanup()

server := "smb-server.default.svc.cluster.local"
if isWindowsCluster {
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())

server = strings.TrimSuffix(string(output), "\n")
log.Printf("use server on Windows: %s\n", server)
}

pods := []testsuites.PodDetails{
{
Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data"),
Expand Down Expand Up @@ -960,10 +980,10 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
CSIDriver: testDriver,
Pods: pods,
SecretName: secretName,
Server: server,
ShareName: "share",
ReadOnly: false,
CSIInlineVolume: true,
Server: "smb-server.default.svc.cluster.local",
}
test.Run(cs, ns)
})
Expand Down
18 changes: 18 additions & 0 deletions test/utils/get_smb_svc_public_ip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

#!/bin/bash

set -e
kubectl get svc smb-server | grep smb | awk '{print $4}'

0 comments on commit 7d52167

Please sign in to comment.