- Notifications
You must be signed in to change notification settings - Fork928
chore: fix flake in apptest reconnecting-pty test#7281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -22,7 +22,6 @@ import ( | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"golang.org/x/xerrors" | ||
"github.com/coder/coder/coderd/coderdtest" | ||
"github.com/coder/coder/coderd/rbac" | ||
@@ -72,7 +71,13 @@ func Run(t *testing.T, factory DeploymentFactory) { | ||
// Run the test against the path app hostname since that's where the | ||
// reconnecting-pty proxy server we want to test is mounted. | ||
client := appDetails.AppClient(t) | ||
conn, err := client.WorkspaceAgentReconnectingPTY(ctx, codersdk.WorkspaceAgentReconnectingPTYOpts{ | ||
AgentID: appDetails.Agent.ID, | ||
Reconnect: uuid.New(), | ||
Height: 80, | ||
Width: 80, | ||
Command: "/bin/bash", | ||
}) | ||
require.NoError(t, err) | ||
defer conn.Close() | ||
@@ -125,29 +130,42 @@ func Run(t *testing.T, factory DeploymentFactory) { | ||
}) | ||
require.NoError(t, err) | ||
// Make an unauthenticated client. | ||
unauthedAppClient := codersdk.New(appDetails.AppClient(t).URL) | ||
conn, err := unauthedAppClient.WorkspaceAgentReconnectingPTY(ctx, codersdk.WorkspaceAgentReconnectingPTYOpts{ | ||
AgentID: appDetails.Agent.ID, | ||
Reconnect: uuid.New(), | ||
Height: 80, | ||
Width: 80, | ||
Command: "/bin/bash", | ||
SignedToken: issueRes.SignedToken, | ||
}) | ||
require.NoError(t, err) | ||
defer conn.Close() | ||
// First attempt to resize the TTY. | ||
// The websocket will close if it fails! | ||
data, err := json.Marshal(codersdk.ReconnectingPTYRequest{ | ||
Height: 250, | ||
Width: 250, | ||
}) | ||
require.NoError(t, err) | ||
_, err = conn.Write(data) | ||
require.NoError(t, err) | ||
bufRead := bufio.NewReader(conn) | ||
// Brief pause to reduce the likelihood that we send keystrokes while | ||
// the shell is simultaneously sending a prompt. | ||
time.Sleep(100 * time.Millisecond) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I guess we can't expect prompt first? If we could set env PS1=> then we'd have something to look for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. PS1 doesn't seem to be accepted through env in bash, only as a variable | ||
data, err = json.Marshal(codersdk.ReconnectingPTYRequest{ | ||
Data: "echo test\r\n", | ||
}) | ||
require.NoError(t, err) | ||
_, err = conn.Write(data) | ||
require.NoError(t, err) | ||
expectLine(t, bufRead, matchEchoCommand) | ||
expectLine(t, bufRead, matchEchoOutput) | ||
}) | ||
}) | ||