From 627b0189e0de8db71758507ee8df557b5f3843bb Mon Sep 17 00:00:00 2001 From: Dominik Froehlich Date: Thu, 22 Jun 2023 16:21:59 +0200 Subject: [PATCH] wip --- acceptance-tests/basic_pcap_test.go | 15 +++++++++------ acceptance-tests/bosh_helpers.go | 2 +- acceptance-tests/remote.go | 8 +++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/acceptance-tests/basic_pcap_test.go b/acceptance-tests/basic_pcap_test.go index 85fab565..1edff87b 100644 --- a/acceptance-tests/basic_pcap_test.go +++ b/acceptance-tests/basic_pcap_test.go @@ -3,8 +3,8 @@ package acceptance_tests import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "os" "os/exec" - "time" ) var _ = Describe("Pcap Deployment", func() { @@ -19,17 +19,20 @@ var _ = Describe("Pcap Deployment", func() { true, ) - err := downloadFile(info, "/var/vcap/packages/pcap-api/bin/cli/build/pcap-bosh-cli-linux-amd64", "/usr/local/bin/pcap-bosh-cli", 0755) + boshCliFile, err := os.CreateTemp("", "pcap-bosh-cli-*") Expect(err).NotTo(HaveOccurred()) - time.Sleep(2 * time.Hour) + boshCli := boshCliFile.Name() - cmd := exec.Command("which", "pcap-bosh-cli") + By("Downloading remote pcap-bosh-cli-linux-amd64 to " + boshCli) + err = downloadFile(info, "/var/vcap/packages/pcap-api/bin/cli/build/pcap-bosh-cli-linux-amd64", boshCli, 0755) + Expect(err).NotTo(HaveOccurred()) + + cmd := exec.Command(boshCli, "--help") helpTest, err := cmd.Output() Expect(err).NotTo(HaveOccurred()) - GinkgoLogr.Info(string(helpTest)) - + writeLog(string(helpTest)) }) }) diff --git a/acceptance-tests/bosh_helpers.go b/acceptance-tests/bosh_helpers.go index 064206a9..ce77c2f1 100644 --- a/acceptance-tests/bosh_helpers.go +++ b/acceptance-tests/bosh_helpers.go @@ -288,5 +288,5 @@ func writeLog(s string) { } func downloadFile(info pcapAPIInfo, remotePath, localPath string, permissions os.FileMode) error { - return copyFileFromRemote(info.SSHUser, info.PublicIP, info.SSHPrivateKey, "/var/vcap/packages/pcap-api/bin/cli/build/pcap-bosh-cli-linux-amd64", "/usr/local/bin/pcap-bosh-cli", 0755) + return copyFileFromRemote(info.SSHUser, info.PublicIP, info.SSHPrivateKey, remotePath, localPath, permissions) } diff --git a/acceptance-tests/remote.go b/acceptance-tests/remote.go index 31ae2f07..1a87dd99 100644 --- a/acceptance-tests/remote.go +++ b/acceptance-tests/remote.go @@ -72,7 +72,13 @@ func copyFileFromRemote(user string, addr string, privateKey string, remotePath return err } - return scpClient.CopyFromRemote(context.Background(), localFile, remotePath) + err = scpClient.CopyFromRemote(context.Background(), localFile, remotePath) + + if err != nil { + return err + } + + return localFile.Sync() } // Forwards a TCP connection from a given port on the local machine to a given port on the remote machine