Skip to content

Commit

Permalink
fix: failing test due to format
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Trivedi <[email protected]>
  • Loading branch information
kushthedude committed Aug 28, 2020
1 parent 42aae4d commit 28ee36c
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 25 deletions.
6 changes: 2 additions & 4 deletions clusterloader2/cmd/clusterloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ func initClusterFlags() {
flags.BoolEnvVar(&clusterLoaderConfig.ClusterConfig.DeleteStaleNamespaces, "delete-stale-namespaces", "DELETE_STALE_NAMESPACES", false, "DEPRECATED: Whether to delete all stale namespaces before the test execution.")
err := flags.MarkDeprecated("delete-stale-namespaces", "specify deleteStaleNamespaces in testconfig file instead.")
if err != nil {
klog.Fatal("unable to mark flag deprecated %v", err)
return
klog.Fatalf("unable to mark flag delete-stale-namespaces deprecated %v", err)
}
flags.BoolEnvVar(&clusterLoaderConfig.ClusterConfig.DeleteAutomanagedNamespaces, "delete-automanaged-namespaces", "DELETE_AUTOMANAGED_NAMESPACES", true, "DEPRECATED: Whether to delete all automanaged namespaces after the test execution.")
err = flags.MarkDeprecated("delete-automanaged-namespaces", "specify deleteAutomanagedNamespaces in testconfig file instead.")
if err != nil {
klog.Fatal("unable to mark flag deprecated %v", err)
return
klog.Fatalf("unable to mark flag delete-automanaged-namespaces deprecated %v", err)
}
flags.StringEnvVar(&clusterLoaderConfig.ClusterConfig.MasterName, "mastername", "MASTER_NAME", "", "Name of the masternode")
// TODO(#595): Change the name of the MASTER_IP and MASTER_INTERNAL_IP flags and vars to plural
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ const (

func init() {
if err := measurement.Register(serviceCreationLatencyName, createServiceCreationLatencyMeasurement); err != nil {
klog.Errorf("cant register service %v", err)
return
klog.Fatalf("cant register service %v", err)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ var (
klogLogToStderr = true
)

func turnOffLoggingToStderrInKlog() {
func turnOffLoggingToStderrInKlog(t *testing.T) {
if klogLogToStderr {
klog.InitFlags(nil)
err := flag.Set("logtostderr", "false")
if err != nil {
klog.Errorf("Unable to set flag %v", err)
t.Errorf("Unable to set flag %v", err)
return
}
err = flag.Set("v", "2")
if err != nil {
klog.Errorf("Unable to set flag %v", err)
t.Errorf("Unable to set flag %v", err)
return
}
flag.Parse()
Expand Down Expand Up @@ -562,7 +562,7 @@ func TestLogging(t *testing.T) {
},
}

turnOffLoggingToStderrInKlog()
turnOffLoggingToStderrInKlog(t)

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand All @@ -575,7 +575,7 @@ func TestLogging(t *testing.T) {

_, err := gatherer.Gather(executor, time.Now(), config)
if err != nil {
klog.Errorf("cant gather config %v", err)
t.Errorf("cant gather config %v", err)
return
}
klog.Flush()
Expand Down Expand Up @@ -729,7 +729,7 @@ func TestAPIResponsivenessCustomThresholds(t *testing.T) {
},
}

turnOffLoggingToStderrInKlog()
turnOffLoggingToStderrInKlog(t)

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ const (

func init() {
if err := measurement.Register(podStartupLatencyMeasurementName, createPodStartupLatencyMeasurement); err != nil {
klog.Errorf("cant register service %v", err)
return
klog.Fatalf("cant register service %v", err)
}
}

Expand Down
8 changes: 4 additions & 4 deletions network/benchmarks/netperf/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func cleanup(c *kubernetes.Clientset) {
err := c.Core().Services(testNamespace).Delete(
svc.GetName(), &metav1.DeleteOptions{})
if err != nil {
fmt.Println("Failed to get services", err)
fmt.Println("Failed to get service", err)
}
}
}
Expand All @@ -150,7 +150,7 @@ func createServices(c *kubernetes.Clientset) bool {
if _, err := c.Core().Namespaces().Get(testNamespace, metav1.GetOptions{}); err != nil {
_, err := c.Core().Namespaces().Create(&api.Namespace{ObjectMeta: metav1.ObjectMeta{Name: testNamespace}})
if err != nil {
fmt.Println("Failed to create services", err)
fmt.Println("Failed to create service", err)
}
}

Expand Down Expand Up @@ -352,7 +352,7 @@ func processCsvData(csvData *string) bool {
if _, err := os.Stat(outputFileDirectory); os.IsNotExist(err) {
err := os.Mkdir(outputFileDirectory, 0766)
if err != nil {
fmt.Println("Error creating directory %v", err)
fmt.Println("Error creating directory", err)
return false
}

Expand All @@ -364,7 +364,7 @@ func processCsvData(csvData *string) bool {
}
_, err = fd.WriteString(*csvData)
if err != nil {
fmt.Println("Error writing string %v", err)
fmt.Println("Error writing string", err)
return false
}
fd.Close()
Expand Down
6 changes: 1 addition & 5 deletions network/benchmarks/netperf/nptest/nptest.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ func serveRPCRequests(port string) {
err := rpc.Register(baseObject)
if err != nil {
log.Fatal("failed to register rpc", err)
return
}
rpc.HandleHTTP()
listener, e := net.Listen("tcp", ":"+port)
Expand All @@ -521,8 +520,7 @@ func serveRPCRequests(port string) {
}
err = http.Serve(listener, nil)
if err != nil {
log.Fatal("failed to start server", err)
return
log.Fatal("failed start server", err)
}
}

Expand Down Expand Up @@ -566,15 +564,13 @@ func handleClientWorkItem(client *rpc.Client, workItem *WorkItem) {
err := client.Call("NetPerfRPC.ReceiveOutput", WorkerOutput{Output: outputString, Worker: worker, Type: workItem.ClientItem.Type}, &reply)
if err != nil {
log.Fatal("failed to call client", err)
return
}
case workItem.ClientItem.Type == netperfTest:
outputString := netperfClient(workItem.ClientItem.Host, workItem.ClientItem.Port, workItem.ClientItem.Type)
var reply int
err := client.Call("NetPerfRPC.ReceiveOutput", WorkerOutput{Output: outputString, Worker: worker, Type: workItem.ClientItem.Type}, &reply)
if err != nil {
log.Fatal("failed to call client", err)
return
}
}
// Client COOLDOWN period before asking for next work item to replenish burst allowance policers etc
Expand Down
2 changes: 1 addition & 1 deletion util-images/access-tokens/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func main() {
func initFlagsAndKlog() {
err := flag.Set("alsologtostderr", "true")
if err != nil {
klog.Warningf("Got error while setting flag to true %v", err)
klog.Warningf("Got error while setting flag alsologtostderr to true %v", err)
return
}
klogFlags := goflag.NewFlagSet("klog", goflag.ExitOnError)
Expand Down
2 changes: 1 addition & 1 deletion util-images/probes/pkg/ping/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ func pong(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte("pong"))
if err != nil {
klog.Fatal("unable to write response %v\n", err)
klog.Fatalf("unable to write response %v\n", err)
}
}

0 comments on commit 28ee36c

Please sign in to comment.