Skip to content
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

Connect refactor #4

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
21c62b2
move reusable grpc components into a base class
hotpocket Dec 5, 2024
1000516
Add ConnectSerializer and the code to select and run it. Refactor ker…
hotpocket Dec 5, 2024
c616b3c
handle error on missing tls similar to kernelServer. Add missing call…
hotpocket Dec 6, 2024
ea26204
add missing config block
hotpocket Dec 6, 2024
a302049
creating the maskedNotebook using `new` causes cells to be copied by …
hotpocket Dec 12, 2024
a9b0554
Merge branch 'main' into connect-refactor
hotpocket Dec 12, 2024
68ea437
getOutputsUri no longer resides on GrpcSerializer and thus broke this…
hotpocket Dec 12, 2024
49fe3a7
replace GrpcSerializer with ConnectSerializer and fix types as needed.
hotpocket Dec 12, 2024
827354a
client init in serializer.ts now calls `getTLSEnabled()` which needs`…
hotpocket Dec 12, 2024
052b70f
i have no idea what's going on here but this makes it work.
hotpocket Dec 12, 2024
10c9c8e
Merge branch 'main' into connect-refactor
hotpocket Dec 13, 2024
70fc30d
fix struct and data items that differ in new implementation.
hotpocket Dec 13, 2024
af02abc
fix typo
hotpocket Dec 13, 2024
81c8c03
fix invalid proto prop reference
hotpocket Dec 15, 2024
14b0f52
combine grpc base and grpc serializer. reorder changes to minimize PR…
hotpocket Dec 15, 2024
99964a2
more diff consolidation for PR
hotpocket Dec 15, 2024
f9f3e1b
pr diff cleanup
hotpocket Dec 17, 2024
f1e08e3
Merge branch 'main' into connect-refactor
hotpocket Dec 18, 2024
e4c2507
fix old schema via foyle npm update
hotpocket Dec 20, 2024
64f5b2b
Merge branch 'main' into connect-refactor
hotpocket Dec 20, 2024
1aa7dfe
expose TLS methods to avoid code duplication
hotpocket Dec 20, 2024
f9144e2
remove stale comment
hotpocket Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions tests/extension/serializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
} from 'vscode'
import { expect, vi, it, describe, beforeEach } from 'vitest'
import { isValid } from 'ulidx'
import { RunmeIdentity, Notebook } from '@buf/stateful_runme.bufbuild_es/runme/parser/v1/parser_pb'

import {
GrpcSerializer,
SerializerBase,
WasmSerializer,
GrpcSerializerBase,
} from '../../src/extension/serializer'
import { RunmeIdentity } from '../../src/extension/grpc/serializerTypes'
import type { Kernel } from '../../src/extension/kernel'
import { EventEmitter, Uri } from '../../__mocks__/vscode'
import { Serializer } from '../../src/types'
Expand Down Expand Up @@ -373,7 +373,7 @@ describe('GrpcSerializer', () => {
const serializer: any = new GrpcSerializer(context, new Server(), new Kernel())
serializer.client = {
deserialize: vi.fn().mockResolvedValue({
response: { notebook: { cells: descells, metadata } },
notebook: { cells: descells, metadata },
}),
}
vi.mocked(workspace.applyEdit).mockResolvedValue(true)
Expand Down Expand Up @@ -471,8 +471,8 @@ describe('GrpcSerializer', () => {
expect(summary?.success).toStrictEqual(false)

expect(summary?.timing).toBeDefined()
expect(summary?.timing?.startTime).toStrictEqual('1701444499517')
expect(summary?.timing?.endTime).toStrictEqual('1701444501696')
expect(summary?.timing?.startTime).toStrictEqual(1701444499517n)
expect(summary?.timing?.endTime).toStrictEqual(1701444501696n)
})
})

Expand All @@ -487,6 +487,8 @@ describe('GrpcSerializer', () => {
const items = cells.outputs[0].items
expect(items.length).toBe(2)
items.forEach((item) => {
// item.data is a Uint8Array in both the es and ts proto type
hotpocket marked this conversation as resolved.
Show resolved Hide resolved
// is this a bug? if so where: in the fixture, the proto, the serializer?
expect((item.data as any).type).toBe('Buffer')
expect(item.mime).toBeDefined()
})
Expand All @@ -495,7 +497,7 @@ describe('GrpcSerializer', () => {
expect(processInfo?.exitReason?.type).toStrictEqual('exit')
expect(processInfo?.exitReason?.code).toStrictEqual(16)
expect(processInfo?.pid).toBeDefined()
expect(processInfo?.pid).toStrictEqual('98354')
expect(processInfo?.pid).toStrictEqual(98354n)
})
})

Expand Down Expand Up @@ -632,7 +634,7 @@ describe('GrpcSerializer', () => {
const fixture = deepCopyFixture()
const writeableSer: any = new GrpcSerializer(context, new Server(), new Kernel())
writeableSer.client = {
serialize: vi.fn().mockResolvedValue({ response: { result: fakeCachedBytes } }),
serialize: vi.fn().mockResolvedValue({ result: fakeCachedBytes }),
}
writeableSer.cacheDocUriMapping.set(fixture.metadata['runme.dev/cacheId'], fakeSrcDocUri)
ContextState.getKey = vi.fn().mockImplementation(() => true)
Expand Down Expand Up @@ -681,20 +683,18 @@ describe('GrpcSerializer', () => {
const context: any = {
extensionUri: { fsPath: '/foo/bar' },
}
const fixture = {
const fixture = new Notebook({
cells: [],
metadata: {
'runme.dev/finalLineBreaks': '1',
'runme.dev/frontmatter':
'---\nrunme:\n id: 01HF7B0KJPF469EG9ZWDNKKACQ\n version: v2.0\n---',
},
}
})

const serialize = vi.fn().mockImplementation(() =>
Promise.resolve({
response: {
result: new Uint8Array([4, 3, 2, 1]),
},
result: new Uint8Array([4, 3, 2, 1]),
}),
)
const ser = new GrpcSerializer(context, new Server(), new Kernel())
Expand Down