-
Notifications
You must be signed in to change notification settings - Fork 943
fix: Use WebSockets to stream workspace build logs #2569
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1c49916
fix: Use WebSockets to stream workspace build logs
kylecarbs 700b591
Update site/src/xServices/workspaceBuild/workspaceBuildXService.ts
kylecarbs f46d188
Update site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx
kylecarbs 23134e4
Update site/src/api/api.ts
kylecarbs 58e060f
Remove unused prop
kylecarbs 67a0664
Merge branch 'main' into wslogs
kylecarbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
fix: Use WebSockets to stream workspace build logs
This was using a streaming HTTP request before, which didn't work on my version of Chrome. This method seemed less reliable and standard than a WebSocket, so figured switching would be best.
- Loading branch information
commit 1c49916e9b75341d5c2c7e386fe53b39602f6712
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 19 additions & 14 deletions
33
site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
import { screen } from "@testing-library/react" | ||
import * as API from "../../api/api" | ||
import { MockWorkspace, MockWorkspaceBuild, renderWithAuth } from "../../testHelpers/renderHelpers" | ||
import WS from "jest-websocket-mock" | ||
import { | ||
MockWorkspace, | ||
MockWorkspaceBuild, | ||
renderWithAuth, | ||
} from "../../testHelpers/renderHelpers" | ||
import { WorkspaceBuildPage } from "./WorkspaceBuildPage" | ||
|
||
describe("WorkspaceBuildPage", () => { | ||
it("renders the stats and logs", async () => { | ||
jest.spyOn(API, "streamWorkspaceBuildLogs").mockResolvedValueOnce({ | ||
read() { | ||
return Promise.resolve({ | ||
value: undefined, | ||
done: true, | ||
}) | ||
}, | ||
releaseLock: jest.fn(), | ||
closed: Promise.resolve(undefined), | ||
cancel: jest.fn(), | ||
}) | ||
const server = new WS("ws://localhost/api/v2/workspacebuilds/" + MockWorkspaceBuild.id + "/logs") | ||
kylecarbs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
renderWithAuth(<WorkspaceBuildPage />, { | ||
route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, | ||
path: "/@:username/:workspace/builds/:buildNumber", | ||
}) | ||
|
||
await server.connected | ||
const log = { | ||
id: "70459334-4878-4bda-a546-98eee166c4c6", | ||
created_at: "2022-05-19T16:46:02.283Z", | ||
log_source: "provisioner_daemon", | ||
log_level: "info", | ||
stage: "Another stage", | ||
output: "", | ||
} | ||
server.send(JSON.stringify(log)) | ||
await screen.findByText(MockWorkspaceBuild.workspace_name) | ||
await screen.findByText(log.stage) | ||
server.close() | ||
}) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.