Skip to content

Commit e8635a0

Browse files
Switch GKE Pods to execute on TB
1 parent c266ee6 commit e8635a0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v0.0.61 Switch GKE Pods to execute on TB
4+
- Interacting with GKE Pod functions new needs testing.TB object.
5+
36
## v0.0.60 Allow TraceExporterOption
47
- Enable passing options to `DiscoverServices` via `WithTraceExporterOption`
58

pkg/gke/test/pods.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package test
22

33
import (
44
"context"
5-
"fmt"
65
"os"
76
"sync"
7+
"testing"
88

99
"github.com/otto-de/sherlock-microservice/pkg/gke"
1010
core "k8s.io/api/core/v1"
@@ -25,16 +25,16 @@ type PodRun struct {
2525

2626
// NewPodRun is starting a remote Pod and streams its output locally.
2727
// Output gets written using provided streams.
28-
func NewPodRunWithStreams(clientset *kubernetes.Clientset, ctx context.Context, pod *core.Pod, streams genericclioptions.IOStreams) *PodRun {
28+
func NewPodRunWithStreams(tb testing.TB, clientset *kubernetes.Clientset, ctx context.Context, pod *core.Pod, streams genericclioptions.IOStreams) *PodRun {
2929

3030
pods := clientset.CoreV1().Pods(pod.Namespace)
3131

32-
fmt.Fprintln(streams.Out, "Creating Test Pod")
32+
tb.Log("Creating Test Pod\n")
3333
pod, err := pods.Create(ctx, pod, metav1.CreateOptions{})
3434
if err != nil {
3535
panic(err)
3636
}
37-
fmt.Fprintf(streams.Out, "Created Test Pod `%s`\n", pod.Name)
37+
tb.Logf("Created Test Pod `%s`\n", pod.Name)
3838

3939
pr := &PodRun{
4040
ctx: ctx,
@@ -56,19 +56,19 @@ func NewPodRunWithStreams(clientset *kubernetes.Clientset, ctx context.Context,
5656

5757
// NewPodRun is starting a remote Pod and streams its output locally.
5858
// Output gets written to Stdout and Stderr.
59-
func NewPodRun(clientset *kubernetes.Clientset, ctx context.Context, pod *core.Pod) *PodRun {
59+
func NewPodRun(tb testing.TB, clientset *kubernetes.Clientset, ctx context.Context, pod *core.Pod) *PodRun {
6060

6161
streams := genericclioptions.IOStreams{
6262
In: nil,
6363
Out: os.Stdout,
6464
ErrOut: os.Stderr,
6565
}
66-
return NewPodRunWithStreams(clientset, ctx, pod, streams)
66+
return NewPodRunWithStreams(tb, clientset, ctx, pod, streams)
6767
}
6868

6969
// Close waits until there is no more output to stream. Then deletes the Pod.
70-
func (pr *PodRun) Close() error {
70+
func (pr *PodRun) Close(tb testing.TB) error {
7171
pr.logStreaming.Wait()
72-
fmt.Fprintf(pr.streams.Out, "Deleting Test Pod `%s`\n", pr.Pod.Name)
72+
tb.Logf("Deleting Test Pod `%s`\n", pr.Pod.Name)
7373
return pr.pods.Delete(pr.ctx, pr.Pod.Name, metav1.DeleteOptions{})
7474
}

0 commit comments

Comments
 (0)