Skip to content

Commit 8622835

Browse files
committed
Split up testing/integration/internal
This moves testing/integration/internal into several more specific packages to prepare to refactor the rest and dedup with the main envtest code.
1 parent 7181f11 commit 8622835

15 files changed

+51
-27
lines changed

pkg/internal/testing/integration/addr/manager.go renamed to pkg/internal/testing/addr/manager.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"time"
88
)
99

10+
// TODO(directxman12): interface / release functionality for external port managers
11+
1012
const (
1113
portReserveTime = 1 * time.Minute
1214
portConflictRetry = 100

pkg/internal/testing/integration/addr/manager_test.go renamed to pkg/internal/testing/addr/manager_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package addr_test
22

33
import (
4-
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/addr"
5-
64
"net"
75
"strconv"
86

97
. "github.com/onsi/ginkgo"
108
. "github.com/onsi/gomega"
9+
10+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/addr"
1111
)
1212

1313
var _ = Describe("SuggestAddress", func() {

pkg/internal/testing/integration/internal/tinyca.go renamed to pkg/internal/testing/certs/tinyca.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package certs
22

33
// NB(directxman12): nothing has verified that this has good settings. In fact,
44
// the setting generated here are probably terrible, but they're fine for integration

pkg/internal/testing/integration/apiserver.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import (
99
"path/filepath"
1010
"time"
1111

12-
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/addr"
12+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/addr"
13+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/certs"
1314
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/internal"
15+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/process"
1416
)
1517

1618
// APIServer knows how to run a kubernetes apiserver.
@@ -68,7 +70,7 @@ type APIServer struct {
6870
Out io.Writer
6971
Err io.Writer
7072

71-
processState *internal.ProcessState
73+
processState *process.ProcessState
7274
}
7375

7476
// Start starts the apiserver, waits for it to come up, and returns an error,
@@ -89,9 +91,9 @@ func (s *APIServer) setProcessState() error {
8991

9092
var err error
9193

92-
s.processState = &internal.ProcessState{}
94+
s.processState = &process.ProcessState{}
9395

94-
s.processState.DefaultedProcessInput, err = internal.DoDefaulting(
96+
s.processState.DefaultedProcessInput, err = process.DoDefaulting(
9597
"kube-apiserver",
9698
s.URL,
9799
s.CertDir,
@@ -123,7 +125,7 @@ func (s *APIServer) setProcessState() error {
123125
return err
124126
}
125127

126-
s.processState.Args, err = internal.RenderTemplates(
128+
s.processState.Args, err = process.RenderTemplates(
127129
internal.DoAPIServerArgDefaulting(s.Args), s,
128130
)
129131
return err
@@ -135,7 +137,7 @@ func (s *APIServer) populateAPIServerCerts() error {
135137
return statErr
136138
}
137139

138-
ca, err := internal.NewTinyCA()
140+
ca, err := certs.NewTinyCA()
139141
if err != nil {
140142
return err
141143
}

pkg/internal/testing/integration/control_plane.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99
"k8s.io/client-go/kubernetes/scheme"
1010
"k8s.io/client-go/rest"
1111

12-
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/internal"
12+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/certs"
1313
)
1414

1515
// NewTinyCA creates a new a tiny CA utility for provisioning serving certs and client certs FOR TESTING ONLY.
1616
// Don't use this for anything else!
17-
var NewTinyCA = internal.NewTinyCA
17+
var NewTinyCA = certs.NewTinyCA
1818

1919
// ControlPlane is a struct that knows how to start your test control plane.
2020
//

pkg/internal/testing/integration/etcd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/url"
88

99
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/internal"
10+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/process"
1011
)
1112

1213
// Etcd knows how to run an etcd server.
@@ -55,7 +56,7 @@ type Etcd struct {
5556
Out io.Writer
5657
Err io.Writer
5758

58-
processState *internal.ProcessState
59+
processState *process.ProcessState
5960
}
6061

6162
// Start starts the etcd, waits for it to come up, and returns an error, if one
@@ -72,9 +73,9 @@ func (e *Etcd) Start() error {
7273
func (e *Etcd) setProcessState() error {
7374
var err error
7475

75-
e.processState = &internal.ProcessState{}
76+
e.processState = &process.ProcessState{}
7677

77-
e.processState.DefaultedProcessInput, err = internal.DoDefaulting(
78+
e.processState.DefaultedProcessInput, err = process.DoDefaulting(
7879
"etcd",
7980
e.URL,
8081
e.DataDir,
@@ -94,7 +95,7 @@ func (e *Etcd) setProcessState() error {
9495
e.StartTimeout = e.processState.StartTimeout
9596
e.StopTimeout = e.processState.StopTimeout
9697

97-
e.processState.Args, err = internal.RenderTemplates(
98+
e.processState.Args, err = process.RenderTemplates(
9899
internal.DoEtcdArgDefaulting(e.Args), e,
99100
)
100101
return err

pkg/internal/testing/integration/kubectl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io"
66
"os/exec"
77

8-
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/internal"
8+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/process"
99
)
1010

1111
// KubeCtl is a wrapper around the kubectl binary.
@@ -30,7 +30,7 @@ type KubeCtl struct {
3030
// stderr.
3131
func (k *KubeCtl) Run(args ...string) (stdout, stderr io.Reader, err error) {
3232
if k.Path == "" {
33-
k.Path = internal.BinPathFinder("kubectl")
33+
k.Path = process.BinPathFinder("kubectl")
3434
}
3535

3636
stdoutBuffer := &bytes.Buffer{}

pkg/internal/testing/integration/internal/arguments.go renamed to pkg/internal/testing/process/arguments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package process
22

33
import (
44
"bytes"

pkg/internal/testing/integration/internal/arguments_test.go renamed to pkg/internal/testing/process/arguments_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal_test
1+
package process_test
22

33
import (
44
"net/url"
@@ -7,7 +7,7 @@ import (
77
. "github.com/onsi/gomega"
88

99
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration"
10-
. "sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/internal"
10+
. "sigs.k8s.io/controller-runtime/pkg/internal/testing/process"
1111
)
1212

1313
var _ = Describe("Arguments", func() {

pkg/internal/testing/integration/internal/bin_path_finder.go renamed to pkg/internal/testing/process/bin_path_finder.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package process
22

33
import (
44
"os"
@@ -18,6 +18,8 @@ func init() {
1818
assetsPath = filepath.Join(filepath.Dir(thisFile), "..", "assets", "bin")
1919
}
2020

21+
// TODO(directxman12): unify this with the logic from envtest
22+
2123
// BinPathFinder checks the an environment variable, derived from the symbolic name,
2224
// and falls back to a default assets location when this variable is not set
2325
func BinPathFinder(symbolicName string) (binPath string) {

pkg/internal/testing/integration/internal/bin_path_finder_test.go renamed to pkg/internal/testing/process/bin_path_finder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package process
22

33
import (
44
"os"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package process_test
2+
3+
import (
4+
"testing"
5+
6+
. "github.com/onsi/ginkgo"
7+
. "github.com/onsi/gomega"
8+
9+
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
10+
)
11+
12+
func TestInternal(t *testing.T) {
13+
t.Parallel()
14+
RegisterFailHandler(Fail)
15+
suiteName := "Envtest Process Launcher Suite"
16+
RunSpecsWithDefaultAndCustomReporters(t, suiteName, []Reporter{printer.NewlineReporter{}, printer.NewProwReporter(suiteName)})
17+
}

pkg/internal/testing/integration/internal/process.go renamed to pkg/internal/testing/process/process.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal
1+
package process
22

33
import (
44
"fmt"
@@ -16,7 +16,7 @@ import (
1616
"github.com/onsi/gomega/gbytes"
1717
"github.com/onsi/gomega/gexec"
1818

19-
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/addr"
19+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/addr"
2020
)
2121

2222
// ProcessState define the state of the process.

pkg/internal/testing/integration/internal/process_test.go renamed to pkg/internal/testing/process/process_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package internal_test
1+
package process_test
22

33
import (
44
"bytes"
@@ -15,8 +15,8 @@ import (
1515
. "github.com/onsi/gomega"
1616
"github.com/onsi/gomega/gexec"
1717
"github.com/onsi/gomega/ghttp"
18-
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/addr"
19-
. "sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/internal"
18+
"sigs.k8s.io/controller-runtime/pkg/internal/testing/addr"
19+
. "sigs.k8s.io/controller-runtime/pkg/internal/testing/process"
2020
)
2121

2222
const (

0 commit comments

Comments
 (0)