@datalayer/core 0.0.12 → 0.0.13
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/README.md +2 -2
- package/lib/api/DatalayerApi.d.ts +38 -26
- package/lib/api/DatalayerApi.js +35 -8
- package/lib/api/iam/authentication.d.ts +8 -7
- package/lib/api/iam/authentication.js +14 -15
- package/lib/api/iam/healthz.d.ts +3 -2
- package/lib/api/iam/healthz.js +5 -3
- package/lib/api/iam/index.d.ts +9 -4
- package/lib/api/iam/index.js +9 -4
- package/lib/api/iam/oauth2.d.ts +115 -0
- package/lib/api/iam/oauth2.js +309 -0
- package/lib/api/iam/profile.d.ts +8 -1
- package/lib/api/iam/profile.js +17 -2
- package/lib/api/iam/usage.d.ts +56 -0
- package/lib/api/iam/usage.js +39 -0
- package/lib/api/index.d.ts +6 -5
- package/lib/api/index.js +6 -5
- package/lib/api/runtimes/environments.js +3 -2
- package/lib/api/runtimes/healthz.d.ts +3 -13
- package/lib/api/runtimes/healthz.js +4 -3
- package/lib/api/runtimes/index.d.ts +3 -2
- package/lib/api/runtimes/index.js +3 -2
- package/lib/api/runtimes/runtimes.js +17 -6
- package/lib/api/runtimes/snapshots.js +3 -2
- package/lib/api/spacer/documents.d.ts +12 -0
- package/lib/api/spacer/documents.js +43 -0
- package/lib/api/spacer/healthz.d.ts +3 -13
- package/lib/api/spacer/healthz.js +4 -3
- package/lib/api/spacer/index.d.ts +4 -2
- package/lib/api/spacer/index.js +4 -2
- package/lib/api/spacer/items.d.ts +9 -1
- package/lib/api/spacer/items.js +17 -2
- package/lib/api/spacer/lexicals.js +3 -2
- package/lib/api/spacer/notebooks.js +3 -2
- package/lib/api/spacer/spaces.js +3 -2
- package/lib/api/spacer/users.js +3 -2
- package/lib/api/types/common.d.ts +64 -0
- package/lib/api/types/iam.d.ts +88 -65
- package/lib/api/types/index.d.ts +4 -2
- package/lib/api/types/index.js +4 -2
- package/lib/api/types/runtimes.d.ts +9 -39
- package/lib/api/types/spacer.d.ts +37 -65
- package/lib/api/utils/validation.d.ts +24 -1
- package/lib/api/utils/validation.js +62 -1
- package/lib/client/base.d.ts +75 -0
- package/lib/client/base.js +199 -0
- package/lib/client/constants.d.ts +22 -0
- package/lib/client/constants.js +22 -0
- package/lib/client/index.d.ts +108 -0
- package/lib/client/index.js +79 -0
- package/lib/client/mixins/IAMMixin.d.ts +54 -0
- package/lib/client/mixins/IAMMixin.js +181 -0
- package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
- package/lib/client/mixins/RuntimesMixin.js +229 -0
- package/lib/client/mixins/SpacerMixin.d.ts +111 -0
- package/lib/client/mixins/SpacerMixin.js +340 -0
- package/lib/client/models/Credits.d.ts +91 -0
- package/lib/client/models/Credits.js +130 -0
- package/lib/client/models/Environment.d.ts +73 -0
- package/lib/client/models/Environment.js +88 -0
- package/lib/client/models/HealthCheck.d.ts +72 -0
- package/lib/client/models/HealthCheck.js +107 -0
- package/lib/client/models/Item.d.ts +69 -0
- package/lib/client/models/Item.js +191 -0
- package/lib/client/models/Lexical.d.ts +83 -0
- package/lib/client/models/Lexical.js +152 -0
- package/lib/client/models/Notebook.d.ts +87 -0
- package/lib/client/models/Notebook.js +153 -0
- package/lib/client/models/Runtime.d.ts +122 -0
- package/lib/client/models/Runtime.js +204 -0
- package/lib/client/models/Snapshot.d.ts +92 -0
- package/lib/client/models/Snapshot.js +139 -0
- package/lib/client/models/Space.d.ts +135 -0
- package/lib/client/models/Space.js +234 -0
- package/lib/client/models/User.d.ts +64 -0
- package/lib/client/models/User.js +83 -0
- package/lib/client/models/index.d.ts +26 -0
- package/lib/client/models/index.js +25 -0
- package/lib/client/utils/mixins.d.ts +12 -0
- package/lib/{sdk/client → client}/utils/mixins.js +0 -28
- package/lib/client/utils/spacerUtils.d.ts +18 -0
- package/lib/client/utils/spacerUtils.js +32 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
- package/lib/collaboration/DatalayerCollaboration.js +2 -2
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +2 -2
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
- package/lib/config/Configuration.d.ts +8 -0
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/hooks/useToast.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -2
- package/lib/sdk/index.d.ts +5 -4
- package/lib/sdk/index.js +6 -5
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/CoreState.js +2 -0
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
- package/lib/{sdk/stateful → stateful}/index.js +1 -1
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
- package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
- package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
- package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
- package/lib/stateful/runtimes/apis.js +5 -0
- package/package.json +12 -10
- package/lib/__tests__/hooks.test.d.ts +0 -1
- package/lib/__tests__/hooks.test.js +0 -19
- package/lib/__tests__/index.test.d.ts +0 -1
- package/lib/__tests__/index.test.js +0 -27
- package/lib/__tests__/integration.test.d.ts +0 -1
- package/lib/__tests__/integration.test.js +0 -57
- package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
- package/lib/__tests__/shared/cleanup-shared.js +0 -228
- package/lib/__tests__/shared/test-config.d.ts +0 -51
- package/lib/__tests__/shared/test-config.js +0 -110
- package/lib/__tests__/shared/test-constants.d.ts +0 -66
- package/lib/__tests__/shared/test-constants.js +0 -79
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -59
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.integration.test.js +0 -369
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.integration.test.js +0 -519
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
- package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
- package/lib/api/utils/__tests__/validation.test.js +0 -109
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
- package/lib/sdk/client/base.d.ts +0 -88
- package/lib/sdk/client/base.js +0 -112
- package/lib/sdk/client/index.d.ts +0 -192
- package/lib/sdk/client/index.js +0 -128
- package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
- package/lib/sdk/client/mixins/HealthMixin.js +0 -133
- package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
- package/lib/sdk/client/mixins/IAMMixin.js +0 -83
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
- package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
- package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
- package/lib/sdk/client/models/Lexical.d.ts +0 -156
- package/lib/sdk/client/models/Lexical.js +0 -275
- package/lib/sdk/client/models/Notebook.d.ts +0 -174
- package/lib/sdk/client/models/Notebook.js +0 -311
- package/lib/sdk/client/models/Runtime.d.ts +0 -221
- package/lib/sdk/client/models/Runtime.js +0 -341
- package/lib/sdk/client/models/Snapshot.d.ts +0 -156
- package/lib/sdk/client/models/Snapshot.js +0 -244
- package/lib/sdk/client/models/Space.d.ts +0 -182
- package/lib/sdk/client/models/Space.js +0 -276
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
- package/lib/sdk/client/models/index.d.ts +0 -30
- package/lib/sdk/client/models/index.js +0 -30
- package/lib/sdk/client/utils/mixins.d.ts +0 -42
- /package/lib/{sdk/stateful/runtimes/apis.js → api/types/common.js} +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, beforeAll, afterAll, test } from 'vitest';
|
|
6
|
-
import { runtimes, snapshots } from '../runtimes';
|
|
7
|
-
import { testConfig, debugLog, skipIfNoToken, } from '../../__tests__/shared/test-config';
|
|
8
|
-
import { performCleanup } from '../../__tests__/shared/cleanup-shared';
|
|
9
|
-
let DATALAYER_TOKEN;
|
|
10
|
-
let BASE_URL;
|
|
11
|
-
// Skip all tests if no token is available
|
|
12
|
-
const skipTests = skipIfNoToken();
|
|
13
|
-
beforeAll(async () => {
|
|
14
|
-
if (skipTests) {
|
|
15
|
-
console.log('WARNING: Skipping Runtimes Lifecycle integration tests: No Datalayer API token configured');
|
|
16
|
-
console.log(' Set DATALAYER_API_TOKEN env var or DATALAYER_TEST_TOKEN in .env.test');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
// Get token and base URL from test config
|
|
20
|
-
DATALAYER_TOKEN = testConfig.getToken();
|
|
21
|
-
BASE_URL = testConfig.getBaseUrl('RUNTIMES');
|
|
22
|
-
debugLog('Test configuration loaded');
|
|
23
|
-
debugLog('Base URL:', BASE_URL);
|
|
24
|
-
debugLog('Token available:', !!DATALAYER_TOKEN);
|
|
25
|
-
// Pre-test cleanup
|
|
26
|
-
await performCleanup('setup');
|
|
27
|
-
});
|
|
28
|
-
afterAll(async () => {
|
|
29
|
-
if (skipTests) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// Post-test cleanup
|
|
33
|
-
await performCleanup('teardown');
|
|
34
|
-
}, 30000); // 30 second timeout
|
|
35
|
-
describe.skipIf(skipTests)('Runtimes & Snapshots Lifecycle Integration Tests', () => {
|
|
36
|
-
// Complete lifecycle test for runtimes and snapshots
|
|
37
|
-
// These tests create real resources and incur costs.
|
|
38
|
-
// Run with DATALAYER_TEST_RUN_EXPENSIVE=true to enable
|
|
39
|
-
describe
|
|
40
|
-
.skipIf(testConfig.shouldSkipExpensive())
|
|
41
|
-
.sequential('complete runtime and snapshot lifecycle', () => {
|
|
42
|
-
let pythonRuntimePodName = null;
|
|
43
|
-
let aiRuntimePodName = null;
|
|
44
|
-
let pythonSnapshotUid;
|
|
45
|
-
let aiSnapshotUid;
|
|
46
|
-
const environments = testConfig.getTestEnvironments();
|
|
47
|
-
// No cleanup needed - handled by global setup/teardown
|
|
48
|
-
test('1. should create two runtimes with different environments', { timeout: 60000 }, async () => {
|
|
49
|
-
console.log('Creating runtimes with different environments...');
|
|
50
|
-
// Create Python runtime
|
|
51
|
-
console.log(`Creating Python runtime with environment: ${environments.python}`);
|
|
52
|
-
const pythonCreateData = {
|
|
53
|
-
environment_name: environments.python,
|
|
54
|
-
type: 'notebook',
|
|
55
|
-
given_name: 'test-python-runtime',
|
|
56
|
-
credits_limit: 10,
|
|
57
|
-
};
|
|
58
|
-
const pythonResponse = await runtimes.createRuntime(DATALAYER_TOKEN, pythonCreateData, BASE_URL);
|
|
59
|
-
expect(pythonResponse).toBeDefined();
|
|
60
|
-
expect(pythonResponse.success).toBe(true);
|
|
61
|
-
expect(pythonResponse.runtime).toBeDefined();
|
|
62
|
-
expect(pythonResponse.runtime.pod_name).toBeDefined();
|
|
63
|
-
expect(pythonResponse.runtime.environment_name).toBe(environments.python);
|
|
64
|
-
expect(pythonResponse.runtime.given_name).toBe('test-python-runtime');
|
|
65
|
-
pythonRuntimePodName = pythonResponse.runtime.pod_name;
|
|
66
|
-
console.log(`Created Python runtime: ${pythonRuntimePodName}`);
|
|
67
|
-
// Create AI runtime
|
|
68
|
-
console.log(`Creating AI runtime with environment: ${environments.ai}`);
|
|
69
|
-
const aiCreateData = {
|
|
70
|
-
environment_name: environments.ai,
|
|
71
|
-
type: 'notebook',
|
|
72
|
-
given_name: 'test-ai-runtime',
|
|
73
|
-
credits_limit: 10,
|
|
74
|
-
};
|
|
75
|
-
const aiResponse = await runtimes.createRuntime(DATALAYER_TOKEN, aiCreateData, BASE_URL);
|
|
76
|
-
expect(aiResponse).toBeDefined();
|
|
77
|
-
expect(aiResponse.success).toBe(true);
|
|
78
|
-
expect(aiResponse.runtime).toBeDefined();
|
|
79
|
-
expect(aiResponse.runtime.pod_name).toBeDefined();
|
|
80
|
-
expect(aiResponse.runtime.environment_name).toBe(environments.ai);
|
|
81
|
-
expect(aiResponse.runtime.given_name).toBe('test-ai-runtime');
|
|
82
|
-
aiRuntimePodName = aiResponse.runtime.pod_name;
|
|
83
|
-
console.log(`Created AI runtime: ${aiRuntimePodName}`);
|
|
84
|
-
// Verify both are different
|
|
85
|
-
expect(pythonRuntimePodName).not.toBe(aiRuntimePodName);
|
|
86
|
-
// Wait for runtimes to be ready
|
|
87
|
-
console.log('Waiting for runtimes to be ready...');
|
|
88
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
89
|
-
});
|
|
90
|
-
test('2. should list runtimes and find both created ones', async () => {
|
|
91
|
-
console.log('Listing all runtimes...');
|
|
92
|
-
const response = await runtimes.listRuntimes(DATALAYER_TOKEN, BASE_URL);
|
|
93
|
-
expect(response).toBeDefined();
|
|
94
|
-
expect(response.success).toBe(true);
|
|
95
|
-
expect(response.runtimes).toBeDefined();
|
|
96
|
-
expect(Array.isArray(response.runtimes)).toBe(true);
|
|
97
|
-
// Find our created runtimes
|
|
98
|
-
const pythonRuntime = response.runtimes.find(r => r.pod_name === pythonRuntimePodName);
|
|
99
|
-
const aiRuntime = response.runtimes.find(r => r.pod_name === aiRuntimePodName);
|
|
100
|
-
expect(pythonRuntime).toBeDefined();
|
|
101
|
-
expect(pythonRuntime?.given_name).toBe('test-python-runtime');
|
|
102
|
-
expect(pythonRuntime?.environment_name).toBe(environments.python);
|
|
103
|
-
expect(aiRuntime).toBeDefined();
|
|
104
|
-
expect(aiRuntime?.given_name).toBe('test-ai-runtime');
|
|
105
|
-
expect(aiRuntime?.environment_name).toBe(environments.ai);
|
|
106
|
-
console.log(`Found both runtimes in list. Total runtimes: ${response.runtimes.length}`);
|
|
107
|
-
});
|
|
108
|
-
test('3. should create snapshots of both runtimes', { timeout: 60000 }, async () => {
|
|
109
|
-
console.log('Creating snapshots of both runtimes...');
|
|
110
|
-
// Create snapshot of Python runtime
|
|
111
|
-
console.log('Creating snapshot of Python runtime...');
|
|
112
|
-
const pythonSnapshotData = {
|
|
113
|
-
pod_name: pythonRuntimePodName,
|
|
114
|
-
name: `python-snapshot-${Date.now()}`,
|
|
115
|
-
description: 'Test snapshot for Python runtime',
|
|
116
|
-
stop: false, // Don't stop the runtime after snapshot
|
|
117
|
-
};
|
|
118
|
-
try {
|
|
119
|
-
const pythonSnapshotResponse = await snapshots.createSnapshot(DATALAYER_TOKEN, pythonSnapshotData, BASE_URL);
|
|
120
|
-
console.log('Python snapshot response:', JSON.stringify(pythonSnapshotResponse, null, 2));
|
|
121
|
-
if (pythonSnapshotResponse.success) {
|
|
122
|
-
expect(pythonSnapshotResponse).toHaveProperty('snapshot');
|
|
123
|
-
expect(pythonSnapshotResponse.snapshot).toHaveProperty('uid');
|
|
124
|
-
pythonSnapshotUid = pythonSnapshotResponse.snapshot.uid;
|
|
125
|
-
console.log(`Python snapshot created with UID: ${pythonSnapshotUid}`);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
console.log('Python snapshot creation failed, skipping snapshot tests');
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
console.error('Failed to create Python snapshot:', error.message);
|
|
133
|
-
}
|
|
134
|
-
// Create snapshot of AI runtime
|
|
135
|
-
console.log('Creating snapshot of AI runtime...');
|
|
136
|
-
const aiSnapshotData = {
|
|
137
|
-
pod_name: aiRuntimePodName,
|
|
138
|
-
name: `ai-snapshot-${Date.now()}`,
|
|
139
|
-
description: 'Test snapshot for AI runtime',
|
|
140
|
-
stop: false,
|
|
141
|
-
};
|
|
142
|
-
try {
|
|
143
|
-
const aiSnapshotResponse = await snapshots.createSnapshot(DATALAYER_TOKEN, aiSnapshotData, BASE_URL);
|
|
144
|
-
console.log('AI snapshot response:', JSON.stringify(aiSnapshotResponse, null, 2));
|
|
145
|
-
if (aiSnapshotResponse.success) {
|
|
146
|
-
expect(aiSnapshotResponse).toHaveProperty('snapshot');
|
|
147
|
-
expect(aiSnapshotResponse.snapshot).toHaveProperty('uid');
|
|
148
|
-
aiSnapshotUid = aiSnapshotResponse.snapshot.uid;
|
|
149
|
-
console.log(`AI snapshot created with UID: ${aiSnapshotUid}`);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
console.log('AI snapshot creation failed, skipping snapshot tests');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
console.error('Failed to create AI snapshot:', error.message);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
test('4. should list snapshots and find created ones', async () => {
|
|
160
|
-
if (!pythonSnapshotUid && !aiSnapshotUid) {
|
|
161
|
-
console.log('No snapshots were created, skipping list test');
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
console.log('Listing snapshots to verify creation...');
|
|
165
|
-
const listResponse = await snapshots.listSnapshots(DATALAYER_TOKEN, BASE_URL);
|
|
166
|
-
expect(listResponse).toBeDefined();
|
|
167
|
-
expect(listResponse).toHaveProperty('success');
|
|
168
|
-
expect(listResponse.success).toBe(true);
|
|
169
|
-
expect(listResponse).toHaveProperty('snapshots');
|
|
170
|
-
expect(Array.isArray(listResponse.snapshots)).toBe(true);
|
|
171
|
-
if (pythonSnapshotUid) {
|
|
172
|
-
const foundPythonSnapshot = listResponse.snapshots.find(s => s.uid === pythonSnapshotUid);
|
|
173
|
-
expect(foundPythonSnapshot).toBeDefined();
|
|
174
|
-
console.log('Python snapshot found in list');
|
|
175
|
-
}
|
|
176
|
-
if (aiSnapshotUid) {
|
|
177
|
-
const foundAiSnapshot = listResponse.snapshots.find(s => s.uid === aiSnapshotUid);
|
|
178
|
-
expect(foundAiSnapshot).toBeDefined();
|
|
179
|
-
console.log('AI snapshot found in list');
|
|
180
|
-
}
|
|
181
|
-
console.log(`Total snapshots: ${listResponse.snapshots.length}`);
|
|
182
|
-
});
|
|
183
|
-
test('5. should get snapshot details', async () => {
|
|
184
|
-
if (!pythonSnapshotUid && !aiSnapshotUid) {
|
|
185
|
-
console.log('No snapshots were created, skipping get test');
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
console.log('Getting snapshot details...');
|
|
189
|
-
if (pythonSnapshotUid) {
|
|
190
|
-
const pythonGetResponse = await snapshots.getSnapshot(DATALAYER_TOKEN, pythonSnapshotUid, BASE_URL);
|
|
191
|
-
expect(pythonGetResponse).toBeDefined();
|
|
192
|
-
expect(pythonGetResponse).toHaveProperty('success');
|
|
193
|
-
expect(pythonGetResponse.success).toBe(true);
|
|
194
|
-
expect(pythonGetResponse).toHaveProperty('snapshot');
|
|
195
|
-
expect(pythonGetResponse.snapshot.uid).toBe(pythonSnapshotUid);
|
|
196
|
-
console.log('Python snapshot details retrieved successfully');
|
|
197
|
-
}
|
|
198
|
-
if (aiSnapshotUid) {
|
|
199
|
-
const aiGetResponse = await snapshots.getSnapshot(DATALAYER_TOKEN, aiSnapshotUid, BASE_URL);
|
|
200
|
-
expect(aiGetResponse).toBeDefined();
|
|
201
|
-
expect(aiGetResponse).toHaveProperty('success');
|
|
202
|
-
expect(aiGetResponse.success).toBe(true);
|
|
203
|
-
expect(aiGetResponse).toHaveProperty('snapshot');
|
|
204
|
-
expect(aiGetResponse.snapshot.uid).toBe(aiSnapshotUid);
|
|
205
|
-
console.log('AI snapshot details retrieved successfully');
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
test('6. should restore runtime from snapshot', async () => {
|
|
209
|
-
if (!pythonSnapshotUid) {
|
|
210
|
-
console.log('No Python snapshot was created, skipping restore test');
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
console.log('Testing runtime restoration from snapshot...');
|
|
214
|
-
// Note: The updateRuntime method expects a 'from' parameter
|
|
215
|
-
// which should be the snapshot UID for restoration
|
|
216
|
-
try {
|
|
217
|
-
const restoreResponse = await runtimes.updateRuntime(DATALAYER_TOKEN, pythonRuntimePodName, pythonSnapshotUid, BASE_URL);
|
|
218
|
-
console.log('Restore response:', JSON.stringify(restoreResponse, null, 2));
|
|
219
|
-
console.log('Runtime restored from snapshot successfully');
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
console.log('Restore from snapshot test skipped:', error.message);
|
|
223
|
-
// This might fail if the API doesn't support this operation yet
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
test('7. should delete snapshots', async () => {
|
|
227
|
-
if (!pythonSnapshotUid && !aiSnapshotUid) {
|
|
228
|
-
console.log('No snapshots were created, skipping delete test');
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
console.log('Deleting snapshots...');
|
|
232
|
-
if (pythonSnapshotUid) {
|
|
233
|
-
await snapshots.deleteSnapshot(DATALAYER_TOKEN, pythonSnapshotUid, BASE_URL);
|
|
234
|
-
console.log('Python snapshot deletion request sent');
|
|
235
|
-
// Verify deletion
|
|
236
|
-
try {
|
|
237
|
-
await snapshots.getSnapshot(DATALAYER_TOKEN, pythonSnapshotUid, BASE_URL);
|
|
238
|
-
console.log('WARNING: Python snapshot still exists after deletion (might be soft delete)');
|
|
239
|
-
}
|
|
240
|
-
catch (error) {
|
|
241
|
-
console.log('Python snapshot properly deleted (404 error expected)');
|
|
242
|
-
}
|
|
243
|
-
pythonSnapshotUid = undefined; // Mark as deleted
|
|
244
|
-
}
|
|
245
|
-
if (aiSnapshotUid) {
|
|
246
|
-
await snapshots.deleteSnapshot(DATALAYER_TOKEN, aiSnapshotUid, BASE_URL);
|
|
247
|
-
console.log('AI snapshot deletion request sent');
|
|
248
|
-
// Verify deletion
|
|
249
|
-
try {
|
|
250
|
-
await snapshots.getSnapshot(DATALAYER_TOKEN, aiSnapshotUid, BASE_URL);
|
|
251
|
-
console.log('WARNING: AI snapshot still exists after deletion (might be soft delete)');
|
|
252
|
-
}
|
|
253
|
-
catch (error) {
|
|
254
|
-
console.log('AI snapshot properly deleted (404 error expected)');
|
|
255
|
-
}
|
|
256
|
-
aiSnapshotUid = undefined; // Mark as deleted
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
test('8. should delete Python runtime', async () => {
|
|
260
|
-
console.log(`Deleting Python runtime: ${pythonRuntimePodName}`);
|
|
261
|
-
await runtimes.deleteRuntime(DATALAYER_TOKEN, pythonRuntimePodName, BASE_URL);
|
|
262
|
-
console.log('Python runtime deletion request sent');
|
|
263
|
-
// Mark it as deleted so cleanup doesn't try again
|
|
264
|
-
const deletedPod = pythonRuntimePodName;
|
|
265
|
-
pythonRuntimePodName = null;
|
|
266
|
-
// Verify it's gone
|
|
267
|
-
try {
|
|
268
|
-
await runtimes.getRuntime(DATALAYER_TOKEN, deletedPod, BASE_URL);
|
|
269
|
-
throw new Error('Python runtime should have been deleted');
|
|
270
|
-
}
|
|
271
|
-
catch (error) {
|
|
272
|
-
expect(error.message).toBeDefined();
|
|
273
|
-
console.log('Confirmed: Python runtime is deleted');
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
test('9. should verify Python runtime is deleted but AI runtime exists', async () => {
|
|
277
|
-
console.log('Verifying runtime states...');
|
|
278
|
-
const response = await runtimes.listRuntimes(DATALAYER_TOKEN, BASE_URL);
|
|
279
|
-
// Python runtime should not be in the list
|
|
280
|
-
const pythonRuntime = response.runtimes.find(r => r.given_name === 'test-python-runtime');
|
|
281
|
-
expect(pythonRuntime).toBeUndefined();
|
|
282
|
-
// AI runtime should still be in the list
|
|
283
|
-
const aiRuntime = response.runtimes.find(r => r.pod_name === aiRuntimePodName);
|
|
284
|
-
expect(aiRuntime).toBeDefined();
|
|
285
|
-
expect(aiRuntime?.given_name).toBe('test-ai-runtime');
|
|
286
|
-
console.log('Confirmed: Python runtime deleted, AI runtime still exists');
|
|
287
|
-
});
|
|
288
|
-
test('10. should delete AI runtime', async () => {
|
|
289
|
-
console.log(`Deleting AI runtime: ${aiRuntimePodName}`);
|
|
290
|
-
await runtimes.deleteRuntime(DATALAYER_TOKEN, aiRuntimePodName, BASE_URL);
|
|
291
|
-
console.log('AI runtime deletion request sent');
|
|
292
|
-
// Mark it as deleted so cleanup doesn't try again
|
|
293
|
-
const deletedPod = aiRuntimePodName;
|
|
294
|
-
aiRuntimePodName = null;
|
|
295
|
-
// Verify it's gone
|
|
296
|
-
try {
|
|
297
|
-
await runtimes.getRuntime(DATALAYER_TOKEN, deletedPod, BASE_URL);
|
|
298
|
-
throw new Error('AI runtime should have been deleted');
|
|
299
|
-
}
|
|
300
|
-
catch (error) {
|
|
301
|
-
expect(error.message).toBeDefined();
|
|
302
|
-
console.log('Confirmed: AI runtime is deleted');
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
test('11. should verify both runtimes are deleted', async () => {
|
|
306
|
-
console.log('Final verification: checking both runtimes are deleted...');
|
|
307
|
-
const response = await runtimes.listRuntimes(DATALAYER_TOKEN, BASE_URL);
|
|
308
|
-
// Neither runtime should be in the list
|
|
309
|
-
const pythonRuntime = response.runtimes.find(r => r.given_name === 'test-python-runtime');
|
|
310
|
-
const aiRuntime = response.runtimes.find(r => r.given_name === 'test-ai-runtime');
|
|
311
|
-
expect(pythonRuntime).toBeUndefined();
|
|
312
|
-
expect(aiRuntime).toBeUndefined();
|
|
313
|
-
console.log('Confirmed: Both runtimes successfully deleted');
|
|
314
|
-
console.log('Complete lifecycle test finished successfully!');
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
// Basic smoke tests that always run
|
|
318
|
-
describe('smoke tests', () => {
|
|
319
|
-
it('should successfully list runtime instances', async () => {
|
|
320
|
-
console.log('Testing list runtimes endpoint...');
|
|
321
|
-
const response = await runtimes.listRuntimes(DATALAYER_TOKEN, BASE_URL);
|
|
322
|
-
console.log(`Found ${response.runtimes.length} runtime instances`);
|
|
323
|
-
expect(response).toBeDefined();
|
|
324
|
-
expect(response).toHaveProperty('success');
|
|
325
|
-
expect(response.success).toBe(true);
|
|
326
|
-
expect(response).toHaveProperty('runtimes');
|
|
327
|
-
expect(Array.isArray(response.runtimes)).toBe(true);
|
|
328
|
-
if (response.runtimes.length > 0) {
|
|
329
|
-
const firstRuntime = response.runtimes[0];
|
|
330
|
-
console.log('First runtime pod name:', firstRuntime.pod_name);
|
|
331
|
-
expect(firstRuntime).toHaveProperty('pod_name');
|
|
332
|
-
expect(firstRuntime).toHaveProperty('uid');
|
|
333
|
-
expect(firstRuntime).toHaveProperty('environment_name');
|
|
334
|
-
expect(firstRuntime).toHaveProperty('burning_rate');
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
it('should successfully list runtime snapshots', async () => {
|
|
338
|
-
console.log('Testing list snapshots endpoint...');
|
|
339
|
-
const response = await snapshots.listSnapshots(DATALAYER_TOKEN, BASE_URL);
|
|
340
|
-
console.log(`Found ${response.snapshots.length} runtime snapshots`);
|
|
341
|
-
expect(response).toBeDefined();
|
|
342
|
-
expect(response).toHaveProperty('success');
|
|
343
|
-
expect(response.success).toBe(true);
|
|
344
|
-
expect(response).toHaveProperty('snapshots');
|
|
345
|
-
expect(Array.isArray(response.snapshots)).toBe(true);
|
|
346
|
-
if (response.snapshots.length > 0) {
|
|
347
|
-
const firstSnapshot = response.snapshots[0];
|
|
348
|
-
console.log('First snapshot UID:', firstSnapshot.uid);
|
|
349
|
-
expect(firstSnapshot).toHaveProperty('uid');
|
|
350
|
-
expect(firstSnapshot).toHaveProperty('name');
|
|
351
|
-
expect(firstSnapshot).toHaveProperty('environment');
|
|
352
|
-
expect(firstSnapshot).toHaveProperty('updated_at');
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
it('should handle non-existent runtime gracefully', async () => {
|
|
356
|
-
console.log('Testing get with non-existent pod name...');
|
|
357
|
-
const nonExistentPod = 'non-existent-pod-12345';
|
|
358
|
-
try {
|
|
359
|
-
await runtimes.getRuntime(DATALAYER_TOKEN, nonExistentPod, BASE_URL);
|
|
360
|
-
console.log('WARNING: Non-existent runtime returned data');
|
|
361
|
-
}
|
|
362
|
-
catch (error) {
|
|
363
|
-
console.log('Error for non-existent runtime:', error.message);
|
|
364
|
-
expect(error).toBeDefined();
|
|
365
|
-
expect(error.message).toBeDefined();
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { healthz } from '../spacer';
|
|
7
|
-
import { testConfig, skipIfNoToken } from '../../__tests__/shared/test-config';
|
|
8
|
-
/**
|
|
9
|
-
* Integration tests for Spacer health check API
|
|
10
|
-
* These tests run against the actual Datalayer Spacer API
|
|
11
|
-
*/
|
|
12
|
-
describe('Spacer Healthz Integration Tests', () => {
|
|
13
|
-
describe.skipIf(skipIfNoToken())('ping endpoint', () => {
|
|
14
|
-
it('should successfully ping the Spacer service', async () => {
|
|
15
|
-
console.log('Testing health check ping endpoint for Spacer...');
|
|
16
|
-
const response = await healthz.ping(testConfig.getBaseUrl('SPACER'));
|
|
17
|
-
// Log response for debugging
|
|
18
|
-
console.log('Ping response:', JSON.stringify(response, null, 2));
|
|
19
|
-
// Verify response structure
|
|
20
|
-
expect(response).toBeDefined();
|
|
21
|
-
expect(response.success).toBe(true);
|
|
22
|
-
expect(response.message).toBeDefined();
|
|
23
|
-
// Log success
|
|
24
|
-
console.log('Spacer health check successful');
|
|
25
|
-
console.log('Success:', response.success);
|
|
26
|
-
console.log('Message:', response.message);
|
|
27
|
-
if (response.status) {
|
|
28
|
-
console.log('Status:', response.status.status);
|
|
29
|
-
}
|
|
30
|
-
if (response.version) {
|
|
31
|
-
console.log('Version:', response.version);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
it('should work with default URL if not specified', async () => {
|
|
35
|
-
console.log('Testing health check with default URL...');
|
|
36
|
-
// Use default URL (should use production)
|
|
37
|
-
const response = await healthz.ping();
|
|
38
|
-
expect(response).toBeDefined();
|
|
39
|
-
expect(response.success).toBe(true);
|
|
40
|
-
expect(response.message).toBeDefined();
|
|
41
|
-
console.log('Successfully pinged Spacer service with default URL');
|
|
42
|
-
});
|
|
43
|
-
it('should fail with invalid URL', async () => {
|
|
44
|
-
console.log('Testing health check with invalid URL...');
|
|
45
|
-
const invalidUrl = 'https://invalid.datalayer.run';
|
|
46
|
-
await expect(healthz.ping(invalidUrl)).rejects.toThrow('Health check failed');
|
|
47
|
-
console.log('Correctly failed with invalid URL');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|