forked from gardener/machine-controller-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gardener#2 from amshuman-kr/grpc2
More refactoring. Framework for external driver client. Unit tests.
- Loading branch information
Showing
14 changed files
with
610 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,60 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"path" | ||
"time" | ||
|
||
svr "github.com/gardener/machine-controller-manager/pkg/grpc/infraserver" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials" | ||
"google.golang.org/grpc/testdata" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
var ( | ||
tls = false //"Connection uses TLS if true, else plain TCP" | ||
certFile = "" //"The TLS cert file" | ||
keyFile = "" //"The TLS key file" | ||
port = 10000 //"The server port" | ||
) | ||
|
||
func main() { | ||
svr.StartServer() | ||
server := &svr.ExternalDriverManager{ | ||
Port: port, | ||
UseTLS: tls, | ||
} | ||
if tls { | ||
if certFile == "" { | ||
certFile = testdata.Path("server1.pem") | ||
} | ||
if keyFile == "" { | ||
keyFile = testdata.Path("server1.key") | ||
} | ||
creds, err := credentials.NewServerTLSFromFile(certFile, keyFile) | ||
if err != nil { | ||
log.Fatalf("Failed to generate credentials %v", err) | ||
} | ||
server.Options = []grpc.ServerOption{grpc.Creds(creds)} | ||
} | ||
|
||
server.Start() | ||
|
||
// Test go routine to test end to end flow | ||
go func() { | ||
for { | ||
driver, _ := server.GetDriver(metav1.TypeMeta{ | ||
Kind: "driver", | ||
APIVersion: path.Join("poc", "alpha"), | ||
}) | ||
|
||
time.Sleep(5 * time.Second) | ||
log.Printf("Calling create") | ||
driver.Create("fakeDriver", "a", "b") | ||
|
||
time.Sleep(5 * time.Second) | ||
log.Printf("Calling delete") | ||
driver.Delete("fakeDriver", "a", "b") | ||
} | ||
}() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.