@mavogel/cdk-vscode-server 0.0.60 → 0.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/file_checker.sh +3 -0
- package/.jsii +453 -30
- package/API.md +514 -0
- package/README.md +57 -0
- package/assets/idle-monitor/idle-monitor.lambda/index.js +110 -0
- package/assets/status-check/status-check.lambda/index.js +123 -0
- package/examples/auto-stop/main.ts +75 -0
- package/integ-tests/functions/idle-test-handler.ts +178 -0
- package/integ-tests/functions/login-handler.ts +62 -33
- package/integ-tests/integ.al2023.ts.snapshot/read.13497.1.lock +1 -0
- package/integ-tests/integ.custom-domain.ts.snapshot/read.13497.1.lock +1 -0
- package/integ-tests/integ.stop-on-idle.ts +175 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/IntegStopOnIdleFunctionalityDefaultTestDeployAssertEECF3FC0.assets.json +33 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/IntegStopOnIdleFunctionalityDefaultTestDeployAssertEECF3FC0.template.json +692 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/IntegTestStackStopOnIdle.assets.json +146 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/IntegTestStackStopOnIdle.template.json +3077 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.2819175352ad1ce0dae768e83fc328fb70fb5f10b4a8ff0ccbcb791f02b0716d/index.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.33da23274e25bd9f43638c5d83dad26e3931cbe78d462ffd9a9f565e948b4f5f.lambda/index.js +143 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42.bundle/index.js +30676 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.781ab0ab74634cdaf61539ab208ab777829ef07097ac21f95b9e15a3b1eedc1b.lambda/index.js +57 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.7fa1e366ee8a9ded01fc355f704cff92bfd179574e6f9cfee800a3541df1b200/__entrypoint__.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.7fa1e366ee8a9ded01fc355f704cff92bfd179574e6f9cfee800a3541df1b200/index.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.8dd4be31c5a6cd8750dc55c07c1e2f19596f8a27b032d02c18554ed44eabe065.lambda/index.js +110 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.9d043014be736e8162bcc7ec5590cc6d2ff24fd0d9c73a5c5d595151c5fdad00/index.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/cfn-response.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/consts.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/framework.js +3 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/outbound.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.bdc104ed9cab1b5b6421713c8155f0b753380595356f710400609664d3635eca/util.js +1 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.d061a1ca61c6339fcb77bb6fc19194a60c96bb16531eaf1e4e733b50089512ca/index.js +118 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/asset.efac30c7091c58fed492058fa6403c14f7e58aab8cf4fd595d838b8d5eeec2b9/index.js +6017 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/integ.json +20 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/manifest.json +1942 -0
- package/integ-tests/integ.stop-on-idle.ts.snapshot/tree.json +1 -0
- package/integ-tests/integ.ubuntu.ts.snapshot/read.13497.1.lock +1 -0
- package/lib/idle-monitor/idle-monitor-function.d.ts +13 -0
- package/lib/idle-monitor/idle-monitor-function.js +22 -0
- package/lib/idle-monitor/idle-monitor.d.ts +53 -0
- package/lib/idle-monitor/idle-monitor.js +84 -0
- package/lib/idle-monitor/idle-monitor.lambda.d.ts +2 -0
- package/lib/idle-monitor/idle-monitor.lambda.js +97 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/status-check/status-check-function.d.ts +13 -0
- package/lib/status-check/status-check-function.js +22 -0
- package/lib/status-check/status-check.d.ts +36 -0
- package/lib/status-check/status-check.js +109 -0
- package/lib/status-check/status-check.lambda.d.ts +2 -0
- package/lib/status-check/status-check.lambda.js +104 -0
- package/lib/vscode-server.d.ts +42 -0
- package/lib/vscode-server.js +51 -7
- package/mavogelcdkvscodeserver/go.mod +1 -1
- package/mavogelcdkvscodeserver/jsii/jsii.go +2 -2
- package/mavogelcdkvscodeserver/version +1 -1
- package/package.json +21 -16
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
|
+
import { IntegTest, LogType, InvocationType, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
|
|
4
|
+
import {
|
|
5
|
+
App,
|
|
6
|
+
Duration,
|
|
7
|
+
PhysicalName,
|
|
8
|
+
Stack,
|
|
9
|
+
aws_lambda as lambda,
|
|
10
|
+
} from 'aws-cdk-lib';
|
|
11
|
+
import { InstanceClass, InstanceSize } from 'aws-cdk-lib/aws-ec2';
|
|
12
|
+
import { PolicyStatement, Effect } from 'aws-cdk-lib/aws-iam';
|
|
13
|
+
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
14
|
+
import { VSCodeServer } from '../src/vscode-server';
|
|
15
|
+
|
|
16
|
+
// CDK App for Integration Tests
|
|
17
|
+
const app = new App();
|
|
18
|
+
|
|
19
|
+
// Stack under test
|
|
20
|
+
const stackUnderTest = new Stack(app, 'IntegTestStackStopOnIdle', {
|
|
21
|
+
description: "Integration test for stop-on-idle functionality with fast execution parameters.",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Create VSCodeServer with skipStatusChecks to work around 120s assertion timeout:
|
|
25
|
+
const constructUnderTest = new VSCodeServer(stackUnderTest, 'IntegVSCodeServer', {
|
|
26
|
+
instanceClass: InstanceClass.T4G,
|
|
27
|
+
instanceSize: InstanceSize.LARGE,
|
|
28
|
+
instanceVolumeSize: 8,
|
|
29
|
+
enableAutoStop: true, // Enable automatic instance stop when idle
|
|
30
|
+
idleTimeoutMinutes: 2, // Very short timeout for fast testing (2 minutes)
|
|
31
|
+
idleCheckIntervalMinutes: 1, // Check every 1 minute for fast testing
|
|
32
|
+
skipStatusChecks: true, // Skip status checks for integration tests (Option 2 fallback)
|
|
33
|
+
additionalTags: {
|
|
34
|
+
'IntegTest': 'True',
|
|
35
|
+
'TestType': 'StopOnIdle',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Lambda function to test the stop-on-idle flow
|
|
40
|
+
const idleTestHandler = new NodejsFunction(stackUnderTest, 'idle-test-handler', {
|
|
41
|
+
functionName: PhysicalName.GENERATE_IF_NEEDED,
|
|
42
|
+
entry: path.join(__dirname, 'functions', 'idle-test-handler.ts'),
|
|
43
|
+
runtime: lambda.Runtime.NODEJS_20_X,
|
|
44
|
+
logRetention: 1,
|
|
45
|
+
timeout: Duration.minutes(2), // Max 2m from CDK IntegTest assertion timeout
|
|
46
|
+
bundling: {
|
|
47
|
+
esbuildArgs: {
|
|
48
|
+
"--packages": "bundle",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
environment: {
|
|
52
|
+
INSTANCE_ID: constructUnderTest.instance.instanceId,
|
|
53
|
+
CLOUDFRONT_DOMAIN: constructUnderTest.domainName,
|
|
54
|
+
IDLE_TIMEOUT_MINUTES: '2',
|
|
55
|
+
IDLE_MONITOR_RULE_NAME: constructUnderTest.idleMonitor?.scheduleRule.ruleName ?? '',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Lambda function to test login functionality
|
|
60
|
+
const loginHandler = new NodejsFunction(stackUnderTest, 'login-handler', {
|
|
61
|
+
functionName: PhysicalName.GENERATE_IF_NEEDED,
|
|
62
|
+
entry: path.join(__dirname, 'functions', 'login-handler.ts'),
|
|
63
|
+
runtime: lambda.Runtime.NODEJS_20_X,
|
|
64
|
+
logRetention: 1,
|
|
65
|
+
timeout: Duration.seconds(30),
|
|
66
|
+
bundling: {
|
|
67
|
+
esbuildArgs: {
|
|
68
|
+
"--packages": "bundle",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Grant permissions to check instance status, start instances, and manage EventBridge rules
|
|
74
|
+
idleTestHandler.addToRolePolicy(
|
|
75
|
+
new PolicyStatement({
|
|
76
|
+
effect: Effect.ALLOW,
|
|
77
|
+
actions: [
|
|
78
|
+
'ec2:DescribeInstances',
|
|
79
|
+
'ec2:DescribeInstanceStatus',
|
|
80
|
+
'ec2:StartInstances',
|
|
81
|
+
'cloudwatch:GetMetricStatistics',
|
|
82
|
+
'events:DisableRule',
|
|
83
|
+
'events:DescribeRule',
|
|
84
|
+
],
|
|
85
|
+
resources: ['*'],
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const integ = new IntegTest(app, 'IntegStopOnIdleFunctionality', {
|
|
90
|
+
testCases: [stackUnderTest],
|
|
91
|
+
cdkCommandOptions: {
|
|
92
|
+
destroy: {
|
|
93
|
+
args: {
|
|
94
|
+
force: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Test: Complete stop-on-idle workflow
|
|
102
|
+
*
|
|
103
|
+
* Test phases:
|
|
104
|
+
* 1. verify-auto-stop: Wait for instance to stop after being idle (idle-test-handler)
|
|
105
|
+
* 2. disable-idle-monitor: Disable EventBridge rule to prevent re-stopping (idle-test-handler)
|
|
106
|
+
* 3. start-instance: Start the instance and wait for running state (idle-test-handler)
|
|
107
|
+
* 4. verify-login: Check that VS Code Server is accessible via CloudFront (login-handler)
|
|
108
|
+
*
|
|
109
|
+
* This verifies the complete workflow including recovery after auto-stop.
|
|
110
|
+
* Uses the existing login-handler.ts (same as integ.ubuntu.ts) for login verification.
|
|
111
|
+
*/
|
|
112
|
+
integ.assertions
|
|
113
|
+
// Phase 1: Wait for instance to stop after idle timeout
|
|
114
|
+
.invokeFunction({
|
|
115
|
+
functionName: idleTestHandler.functionName,
|
|
116
|
+
logType: LogType.TAIL,
|
|
117
|
+
invocationType: InvocationType.REQUEST_RESPONSE,
|
|
118
|
+
payload: JSON.stringify({
|
|
119
|
+
testPhase: 'verify-auto-stop',
|
|
120
|
+
domainName: constructUnderTest.domainName,
|
|
121
|
+
instanceId: constructUnderTest.instance.instanceId,
|
|
122
|
+
idleTimeoutMinutes: 2,
|
|
123
|
+
}),
|
|
124
|
+
})
|
|
125
|
+
.expect(ExpectedResult.objectLike({
|
|
126
|
+
Payload: '"STOPPED"',
|
|
127
|
+
}))
|
|
128
|
+
// Phase 2: Disable IdleMonitor EventBridge rule
|
|
129
|
+
.next(
|
|
130
|
+
integ.assertions
|
|
131
|
+
.invokeFunction({
|
|
132
|
+
functionName: idleTestHandler.functionName,
|
|
133
|
+
logType: LogType.TAIL,
|
|
134
|
+
invocationType: InvocationType.REQUEST_RESPONSE,
|
|
135
|
+
payload: JSON.stringify({
|
|
136
|
+
testPhase: 'disable-idle-monitor',
|
|
137
|
+
idleMonitorRuleName: constructUnderTest.idleMonitor?.scheduleRule.ruleName ?? '',
|
|
138
|
+
}),
|
|
139
|
+
})
|
|
140
|
+
.expect(ExpectedResult.objectLike({
|
|
141
|
+
Payload: '"DISABLED"',
|
|
142
|
+
})),
|
|
143
|
+
)
|
|
144
|
+
// Phase 3: Start instance and wait for running state
|
|
145
|
+
.next(
|
|
146
|
+
integ.assertions
|
|
147
|
+
.invokeFunction({
|
|
148
|
+
functionName: idleTestHandler.functionName,
|
|
149
|
+
logType: LogType.TAIL,
|
|
150
|
+
invocationType: InvocationType.REQUEST_RESPONSE,
|
|
151
|
+
payload: JSON.stringify({
|
|
152
|
+
testPhase: 'start-instance',
|
|
153
|
+
instanceId: constructUnderTest.instance.instanceId,
|
|
154
|
+
}),
|
|
155
|
+
})
|
|
156
|
+
.expect(ExpectedResult.objectLike({
|
|
157
|
+
Payload: '"RUNNING"',
|
|
158
|
+
})),
|
|
159
|
+
)
|
|
160
|
+
// Phase 4: Verify login is accessible
|
|
161
|
+
.next(
|
|
162
|
+
integ.assertions
|
|
163
|
+
.invokeFunction({
|
|
164
|
+
functionName: loginHandler.functionName,
|
|
165
|
+
logType: LogType.TAIL,
|
|
166
|
+
invocationType: InvocationType.REQUEST_RESPONSE,
|
|
167
|
+
payload: JSON.stringify({
|
|
168
|
+
domainName: constructUnderTest.domainName,
|
|
169
|
+
password: constructUnderTest.password,
|
|
170
|
+
}),
|
|
171
|
+
})
|
|
172
|
+
.expect(ExpectedResult.objectLike({
|
|
173
|
+
Payload: '"OK"',
|
|
174
|
+
})),
|
|
175
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "41.0.0",
|
|
3
|
+
"files": {
|
|
4
|
+
"530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42": {
|
|
5
|
+
"source": {
|
|
6
|
+
"path": "asset.530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42.bundle",
|
|
7
|
+
"packaging": "zip"
|
|
8
|
+
},
|
|
9
|
+
"destinations": {
|
|
10
|
+
"current_account-current_region": {
|
|
11
|
+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
|
|
12
|
+
"objectKey": "530055f7515b3f0a47900f5df37e729ba40ca977b2d07b952bdefa2b8f883f42.zip",
|
|
13
|
+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"7446b7708749cdac710dac533fa614a603bd7b53819cf0c11fb5fe9d42247d16": {
|
|
18
|
+
"displayName": "IntegStopOnIdleFunctionalityDefaultTestDeployAssertEECF3FC0 Template",
|
|
19
|
+
"source": {
|
|
20
|
+
"path": "IntegStopOnIdleFunctionalityDefaultTestDeployAssertEECF3FC0.template.json",
|
|
21
|
+
"packaging": "file"
|
|
22
|
+
},
|
|
23
|
+
"destinations": {
|
|
24
|
+
"current_account-current_region": {
|
|
25
|
+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
|
|
26
|
+
"objectKey": "7446b7708749cdac710dac533fa614a603bd7b53819cf0c11fb5fe9d42247d16.json",
|
|
27
|
+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"dockerImages": {}
|
|
33
|
+
}
|