-
Notifications
You must be signed in to change notification settings - Fork 5
fix: fix session #148
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
base: master
Are you sure you want to change the base?
fix: fix session #148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,6 +187,153 @@ describe('Session', () => { | |
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('should create session with disableSessionIdReuse when provided', async () => { | ||
| const mockResult = { | ||
| sessionId: 'session-123', | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| disableSessionIdReuse: true, | ||
| }; | ||
|
|
||
| mockFcSdk.createFunctionSession = jest.fn().mockResolvedValue(mockResult); | ||
| mockInputs.args = [ | ||
| 'create', | ||
| '--qualifier', | ||
| 'LATEST', | ||
| '--session-ttl-in-seconds', | ||
| '3600', | ||
| '--session-idle-timeout-in-seconds', | ||
| '1800', | ||
| '--disable-session-id-reuse', | ||
| ]; | ||
| session = new Session(mockInputs); | ||
|
|
||
| const result = await session.create(); | ||
| expect(result).toEqual(mockResult); | ||
| expect(mockFcSdk.createFunctionSession).toHaveBeenCalledWith('test-function', { | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| disableSessionIdReuse: true, | ||
| }); | ||
| }); | ||
|
|
||
| it('should create session with custom sessionId when provided', async () => { | ||
| const mockResult = { | ||
| sessionId: 'custom-session-id', | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| }; | ||
|
|
||
| mockFcSdk.createFunctionSession = jest.fn().mockResolvedValue(mockResult); | ||
| mockInputs.args = [ | ||
| 'create', | ||
| '--qualifier', | ||
| 'LATEST', | ||
| '--session-ttl-in-seconds', | ||
| '3600', | ||
| '--session-idle-timeout-in-seconds', | ||
| '1800', | ||
| '--session-id', | ||
| 'custom-session-id', | ||
| ]; | ||
| session = new Session(mockInputs); | ||
|
|
||
| const result = await session.create(); | ||
| expect(result).toEqual(mockResult); | ||
| expect(mockFcSdk.createFunctionSession).toHaveBeenCalledWith('test-function', { | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| sessionId: 'custom-session-id', | ||
| }); | ||
| }); | ||
|
|
||
| it('should create session with ossMountConfig when provided', async () => { | ||
| const mockResult = { | ||
| sessionId: 'session-123', | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| }; | ||
|
|
||
| mockFcSdk.createFunctionSession = jest.fn().mockResolvedValue(mockResult); | ||
| mockInputs.args = [ | ||
| 'create', | ||
| '--qualifier', | ||
| 'LATEST', | ||
| '--session-ttl-in-seconds', | ||
| '3600', | ||
| '--session-idle-timeout-in-seconds', | ||
| '1800', | ||
| '--oss-mount-config', | ||
| '{"mountPoints":[{"bucketName":"test-bucket","bucketPath":"cn-hangzhou","mountDir":"/mnt/oss","readOnly":false}]}', | ||
| ]; | ||
| session = new Session(mockInputs); | ||
|
|
||
| const result = await session.create(); | ||
| expect(result).toEqual(mockResult); | ||
| expect(mockFcSdk.createFunctionSession).toHaveBeenCalledWith('test-function', { | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| ossMountConfig: { | ||
| mountPoints: [ | ||
| { | ||
| bucketName: 'test-bucket', | ||
| bucketPath: 'cn-hangzhou', | ||
| mountDir: '/mnt/oss', | ||
| readOnly: false, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('should create session with polarFsConfig when provided', async () => { | ||
| const mockResult = { | ||
| sessionId: 'session-123', | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| }; | ||
|
|
||
| mockFcSdk.createFunctionSession = jest.fn().mockResolvedValue(mockResult); | ||
| mockInputs.args = [ | ||
| 'create', | ||
| '--qualifier', | ||
| 'LATEST', | ||
| '--session-ttl-in-seconds', | ||
| '3600', | ||
| '--session-idle-timeout-in-seconds', | ||
| '1800', | ||
| '--polar-fs-config', | ||
| '{"userId":1000,"groupId":1000,"mountPoints":[{"polarDbClusterId":"pc-test","instanceId":"pfs-test","mountDir":"/mnt/polar"}]}', | ||
| ]; | ||
| session = new Session(mockInputs); | ||
|
|
||
| const result = await session.create(); | ||
| expect(result).toEqual(mockResult); | ||
| expect(mockFcSdk.createFunctionSession).toHaveBeenCalledWith('test-function', { | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 3600, | ||
| sessionIdleTimeoutInSeconds: 1800, | ||
| polarFsConfig: { | ||
| userId: 1000, | ||
| groupId: 1000, | ||
| mountPoints: [ | ||
| { | ||
| polarDbClusterId: 'pc-test', | ||
| instanceId: 'pfs-test', | ||
| mountDir: '/mnt/polar', | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
| }); | ||
|
Comment on lines
+296
to
+336
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.
The SDK ♻️ Suggested fix- '--polar-fs-config',
- '{"userId":1000,"groupId":1000,"mountPoints":[{"polarDbClusterId":"pc-test","instanceId":"pfs-test","mountDir":"/mnt/polar"}]}',
+ '--polar-fs-config',
+ '{"userId":1000,"groupId":1000,"mountPoints":[{"instanceId":"pfs-test","mountDir":"/mnt/polar","remoteDir":"/"}]}',And update the expected assertion object to drop 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| describe('get', () => { | ||
|
|
@@ -267,6 +414,18 @@ describe('Session', () => { | |
| }; | ||
|
|
||
| mockFcSdk.updateFunctionSession = jest.fn().mockResolvedValue(mockResult); | ||
| mockInputs.args = [ | ||
| 'update', | ||
| '--session-id', | ||
| 'session-123', | ||
| '--qualifier', | ||
| 'LATEST', | ||
| '--session-ttl-in-seconds', | ||
| '7200', | ||
| '--session-idle-timeout-in-seconds', | ||
| '3600', | ||
| ]; | ||
| session = new Session(mockInputs); | ||
|
|
||
| const result = await session.update(); | ||
| expect(result).toEqual(mockResult); | ||
|
|
@@ -321,6 +480,40 @@ describe('Session', () => { | |
| 'timeout must be a number between 0 and 21600', | ||
| ); | ||
| }); | ||
|
|
||
| it('should update session with disableSessionIdReuse when provided', async () => { | ||
| const mockResult = { | ||
| sessionId: 'session-123', | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 7200, | ||
| sessionIdleTimeoutInSeconds: 3600, | ||
| disableSessionIdReuse: true, | ||
| }; | ||
|
|
||
| mockFcSdk.updateFunctionSession = jest.fn().mockResolvedValue(mockResult); | ||
| mockInputs.args = [ | ||
| 'update', | ||
| '--session-id', | ||
| 'session-123', | ||
| '--qualifier', | ||
| 'LATEST', | ||
| '--session-ttl-in-seconds', | ||
| '7200', | ||
| '--session-idle-timeout-in-seconds', | ||
| '3600', | ||
| '--disable-session-id-reuse', | ||
| ]; | ||
| session = new Session(mockInputs); | ||
|
|
||
| const result = await session.update(); | ||
| expect(result).toEqual(mockResult); | ||
| expect(mockFcSdk.updateFunctionSession).toHaveBeenCalledWith('test-function', 'session-123', { | ||
| qualifier: 'LATEST', | ||
| sessionTTLInSeconds: 7200, | ||
| sessionIdleTimeoutInSeconds: 3600, | ||
| disableSessionIdReuse: true, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('list', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading
bucketPathvalue in ossMountConfig test fixture.bucketPathis a path inside the OSS bucket (e.g."/"or"/my-dir"), not a region. Passing"cn-hangzhou"asbucketPathis confusing test data that could be copied by users reading tests as a reference. Also missingendpoint, which is the real OSS-region-bearing field inOSSMountPoint.♻️ Suggested fix
And update the expected assertion object accordingly.
🤖 Prompt for AI Agents