Skip to content

Commit f7be36e

Browse files
committed
tests: fix terminal tests
1 parent ad08711 commit f7be36e

File tree

10 files changed

+20
-24
lines changed

10 files changed

+20
-24
lines changed

cmd/root.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ func NewRootCmd(f factory.Factory) *cobra.Command {
7777
log.Debugf("Applying extra flags from environment: %s", strings.Join(extraFlags, " "))
7878
}
7979

80+
if globalFlags.Silent {
81+
log.SetLevel(logrus.FatalLevel)
82+
} else if globalFlags.Debug {
83+
log.SetLevel(logrus.DebugLevel)
84+
}
85+
8086
// call inactivity timeout
8187
if globalFlags.InactivityTimeout > 0 {
8288
m, err := idle.NewIdleMonitor()

cmd/run.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ devspace --dependency my-dependency run any-command --any-command-flag
9191
_, err := flagspkg.ApplyExtraFlags(cobraCmd, osArgs, true)
9292
if err != nil {
9393
return err
94-
} else if cmd.Silent {
94+
}
95+
96+
if cmd.Silent {
9597
log.SetLevel(logrus.FatalLevel)
98+
} else if cmd.Debug {
99+
log.SetLevel(logrus.DebugLevel)
96100
}
97101

98102
args := os.Args[index:]

e2e/tests/terminal/terminal.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ package terminal
33
import (
44
"bytes"
55
"context"
6-
"fmt"
76
"github.com/loft-sh/devspace/cmd"
87
"github.com/loft-sh/devspace/cmd/flags"
98
"github.com/loft-sh/devspace/e2e/framework"
109
"github.com/loft-sh/devspace/e2e/kube"
1110
"github.com/loft-sh/devspace/pkg/devspace/devpod"
1211
"github.com/loft-sh/devspace/pkg/util/factory"
1312
"github.com/onsi/ginkgo"
14-
"io/ioutil"
1513
kerrors "k8s.io/apimachinery/pkg/api/errors"
1614
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1715
"k8s.io/apimachinery/pkg/util/wait"
@@ -78,7 +76,6 @@ var _ = DevSpaceDescribe("terminal", func() {
7876
// wait until we get the first hostnames
7977
var podName string
8078
err = wait.PollImmediate(time.Second, time.Minute*3, func() (done bool, err error) {
81-
fmt.Println(buffer.String())
8279
lines := strings.Split(buffer.String(), "\n")
8380
if len(lines) <= 1 {
8481
return false, nil
@@ -90,16 +87,7 @@ var _ = DevSpaceDescribe("terminal", func() {
9087
framework.ExpectNoError(err)
9188

9289
// make sure the pod exists
93-
pod, err := kubeClient.RawClient().CoreV1().Pods(ns).Get(context.TODO(), podName, metav1.GetOptions{})
94-
framework.ExpectNoError(err)
95-
framework.ExpectEqual(pod.Spec.Containers[0].Image, "ubuntu:18.04")
96-
97-
// now make a change to the config
98-
fileContents, err := ioutil.ReadFile("devspace.yaml")
99-
framework.ExpectNoError(err)
100-
newString := strings.Replace(string(fileContents), "ubuntu:18.04", "alpine:3.14", -1)
101-
newString = strings.Replace(newString, "container-0", "container-1", -1)
102-
err = ioutil.WriteFile("devspace.yaml", []byte(newString), 0666)
90+
err = kubeClient.RawClient().CoreV1().Pods(ns).Delete(context.TODO(), podName, metav1.DeleteOptions{})
10391
framework.ExpectNoError(err)
10492

10593
// wait until pod is terminated
@@ -135,10 +123,8 @@ var _ = DevSpaceDescribe("terminal", func() {
135123
framework.ExpectNoError(err)
136124

137125
// make sure the pod exists
138-
pod, err = kubeClient.RawClient().CoreV1().Pods(ns).Get(context.TODO(), podName, metav1.GetOptions{})
126+
_, err = kubeClient.RawClient().CoreV1().Pods(ns).Get(context.TODO(), podName, metav1.GetOptions{})
139127
framework.ExpectNoError(err)
140-
framework.ExpectEqual(pod.Spec.Containers[0].Image, "alpine:3.14")
141-
framework.ExpectEqual(pod.Spec.Containers[0].Name, "container-1")
142128

143129
// make sure command terminates correctly
144130
cancel()

examples/pipelines/devspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: pipelines
33

44
vars:
55
HELLO: test
6-
DEVSPACE_LOG_TIMESTAMPS: true
76

87
pipelines:
98
dev:

pkg/devspace/kubectl/exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ func (client *client) execStreamWithTransport(ctx context.Context, options *Exec
111111
}()
112112

113113
select {
114-
case err = <-errChan:
115-
return err
116114
case <-ctx.Done():
117115
upgradeRoundTripper.Close()
118116
<-errChan
119117
return nil
118+
case err = <-errChan:
119+
return err
120120
}
121121
}
122122

pkg/devspace/services/portforwarding/portforwarding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func startForwarding(ctx *devspacecontext.Context, name string, portMappings []*
140140
}
141141

142142
readyChan := make(chan struct{})
143-
errorChan := make(chan error)
143+
errorChan := make(chan error, 1)
144144
pf, err := ctx.KubeClient.NewPortForwarder(pod, ports, addresses, make(chan struct{}), readyChan, errorChan)
145145
if err != nil {
146146
return errors.Errorf("Error starting port forwarding: %v", err)

pkg/devspace/services/portforwarding/reverse_portforwarding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func startReversePortForwarding(ctx *devspacecontext.Context, name, arch string,
3636
}
3737

3838
errorChan := make(chan error, 2)
39-
closeChan := make(chan error)
39+
closeChan := make(chan struct{})
4040

4141
stdinReader, stdinWriter := io.Pipe()
4242
stdoutReader, stdoutWriter := io.Pipe()

pkg/devspace/services/sync/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (c *controller) startWithWait(ctx *devspacecontext.Context, options *Option
8484
var (
8585
onInitUploadDone chan struct{}
8686
onInitDownloadDone chan struct{}
87-
onError = make(chan error)
87+
onError = make(chan error, 1)
8888
onDone = make(chan struct{})
8989
)
9090

pkg/devspace/services/terminal/terminal.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ fi`,
181181

182182
select {
183183
case <-ctx.Context.Done():
184+
<-errChan
184185
return nil
185186
case err = <-errChan:
186187
if err != nil {

pkg/devspace/tunnel/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func SendData(stream remote.Tunnel_InitTunnelClient, sessions <-chan *tunnel.Ses
186186
}
187187
}
188188

189-
func StartReverseForward(ctx context.Context, reader io.ReadCloser, writer io.WriteCloser, tunnels []*latest.PortMapping, stopChan chan error, namespace string, name string, log logpkg.Logger) error {
189+
func StartReverseForward(ctx context.Context, reader io.ReadCloser, writer io.WriteCloser, tunnels []*latest.PortMapping, stopChan chan struct{}, namespace string, name string, log logpkg.Logger) error {
190190
scheme := "TCP"
191191
closeStreams := make([]chan bool, len(tunnels))
192192
defer func() {

0 commit comments

Comments
 (0)