-
Notifications
You must be signed in to change notification settings - Fork 159
Redid test framework to bring up driver on instance and expose TCP socket with SSH Tunneling #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
f01b25e
fe136c9
6b630c4
6934153
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,9 @@ func (s *nonBlockingGRPCServer) ForceStop() { | |
} | ||
|
||
func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer) { | ||
opts := []grpc.ServerOption{ | ||
grpc.UnaryInterceptor(logGRPC), | ||
} | ||
|
||
u, err := url.Parse(endpoint) | ||
|
||
|
@@ -83,6 +86,8 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c | |
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) { | ||
glog.Fatalf("Failed to remove %s, error: %s", addr, err.Error()) | ||
} | ||
} else if u.Scheme == "tcp" { | ||
addr = u.Host | ||
} else { | ||
glog.Fatalf("%v endpoint scheme not supported", u.Scheme) | ||
} | ||
|
@@ -93,9 +98,6 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c | |
glog.Fatalf("Failed to listen: %v", err) | ||
} | ||
|
||
opts := []grpc.ServerOption{ | ||
grpc.UnaryInterceptor(logGRPC), | ||
} | ||
server := grpc.NewServer(opts...) | ||
s.server = server | ||
|
||
|
@@ -111,6 +113,8 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c | |
|
||
glog.Infof("Listening for connections on address: %#v", listener.Addr()) | ||
|
||
server.Serve(listener) | ||
if err := server.Serve(listener); err != nil { | ||
glog.Warningf("Failed to serve: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a warning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fatal |
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you flatten all these files down one directory? ie, get rid of the second binremote There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
Copyright 2016 The Kubernetes Authors. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix copyright. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
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. | ||
*/ | ||
|
||
package binremote | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"os/exec" | ||
"path" | ||
"path/filepath" | ||
|
||
"github.com/golang/glog" | ||
) | ||
|
||
func CreateDriverArchive(archiveName string) (string, error) { | ||
glog.V(2).Infof("Building archive...") | ||
tarDir, err := ioutil.TempDir("", "gce-pd-archive") | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temporary directory %v", err) | ||
} | ||
defer os.RemoveAll(tarDir) | ||
|
||
// Call the suite function to setup the test package. | ||
err = setupBinaries(tarDir) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to setup test package %q: %v", tarDir, err) | ||
} | ||
|
||
// Build the tar | ||
out, err := exec.Command("tar", "-zcvf", archiveName, "-C", tarDir, ".").CombinedOutput() | ||
if err != nil { | ||
return "", fmt.Errorf("failed to build tar %v. Output:\n%s", err, out) | ||
} | ||
|
||
dir, err := os.Getwd() | ||
if err != nil { | ||
return "", fmt.Errorf("failed to get working directory %v", err) | ||
} | ||
return filepath.Join(dir, archiveName), nil | ||
} | ||
|
||
func setupBinaries(tarDir string) error { | ||
// TODO(dyzz): build the gce driver tests instead | ||
goPath, ok := os.LookupEnv("GOPATH") | ||
if !ok { | ||
return fmt.Errorf("Could not find environment variable GOPATH") | ||
} | ||
binPath := path.Join(goPath, "src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make these paths and "gce-pd" names configurable? (ie i want to use this too) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
// TODO make the driver but from the base dir | ||
out, err := exec.Command("go", "build", "-ldflags", "-X main.vendorVersion=latest", "-o", binPath, "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/cmd").CombinedOutput() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you invoke 'make' instead so that it will use the makefile rules instead of recopying them here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if err != nil { | ||
return fmt.Errorf("Failed to make gce-pd-driver: %v: %v", string(out), err) | ||
} | ||
|
||
// Copy binaries | ||
|
||
if _, err := os.Stat(binPath); err != nil { | ||
return fmt.Errorf("failed to locate test binary %s: %v", "gce-pd-csi-driver", err) | ||
} | ||
out, err = exec.Command("cp", binPath, filepath.Join(tarDir, "gce-pd-csi-driver")).CombinedOutput() | ||
if err != nil { | ||
return fmt.Errorf("failed to copy %q: %v Output: %q", "gce-pd-csi-driver", err, out) | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intent to uncomment this eventually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont need this bin anymore, removed