@datalayer/core 0.0.12 → 0.0.14

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.
Files changed (249) hide show
  1. package/README.md +2 -2
  2. package/lib/api/DatalayerApi.d.ts +38 -26
  3. package/lib/api/DatalayerApi.js +52 -13
  4. package/lib/api/iam/authentication.d.ts +9 -8
  5. package/lib/api/iam/authentication.js +14 -15
  6. package/lib/api/iam/healthz.d.ts +3 -2
  7. package/lib/api/iam/healthz.js +5 -3
  8. package/lib/api/iam/index.d.ts +9 -4
  9. package/lib/api/iam/index.js +9 -4
  10. package/lib/api/iam/oauth2.d.ts +115 -0
  11. package/lib/api/iam/oauth2.js +309 -0
  12. package/lib/api/iam/profile.d.ts +8 -1
  13. package/lib/api/iam/profile.js +17 -2
  14. package/lib/api/iam/usage.d.ts +18 -0
  15. package/lib/api/iam/usage.js +39 -0
  16. package/lib/api/index.d.ts +6 -6
  17. package/lib/api/index.js +6 -7
  18. package/lib/api/runtimes/environments.d.ts +2 -2
  19. package/lib/api/runtimes/environments.js +3 -2
  20. package/lib/api/runtimes/healthz.d.ts +3 -13
  21. package/lib/api/runtimes/healthz.js +4 -3
  22. package/lib/api/runtimes/index.d.ts +3 -2
  23. package/lib/api/runtimes/index.js +3 -2
  24. package/lib/api/runtimes/runtimes.d.ts +4 -4
  25. package/lib/api/runtimes/runtimes.js +17 -6
  26. package/lib/api/runtimes/snapshots.d.ts +4 -4
  27. package/lib/api/runtimes/snapshots.js +3 -2
  28. package/lib/api/spacer/documents.d.ts +12 -0
  29. package/lib/api/spacer/documents.js +43 -0
  30. package/lib/api/spacer/healthz.d.ts +3 -13
  31. package/lib/api/spacer/healthz.js +4 -3
  32. package/lib/api/spacer/index.d.ts +4 -2
  33. package/lib/api/spacer/index.js +4 -2
  34. package/lib/api/spacer/items.d.ts +9 -1
  35. package/lib/api/spacer/items.js +17 -2
  36. package/lib/api/spacer/lexicals.d.ts +1 -1
  37. package/lib/api/spacer/lexicals.js +3 -2
  38. package/lib/api/spacer/notebooks.d.ts +1 -1
  39. package/lib/api/spacer/notebooks.js +3 -2
  40. package/lib/api/spacer/spaces.d.ts +1 -1
  41. package/lib/api/spacer/spaces.js +3 -2
  42. package/lib/api/spacer/users.d.ts +1 -1
  43. package/lib/api/spacer/users.js +3 -2
  44. package/lib/api/utils/validation.d.ts +24 -1
  45. package/lib/api/utils/validation.js +62 -1
  46. package/lib/client/base.d.ts +75 -0
  47. package/lib/client/base.js +199 -0
  48. package/lib/client/constants.d.ts +22 -0
  49. package/lib/client/constants.js +22 -0
  50. package/lib/client/index.d.ts +108 -0
  51. package/lib/client/index.js +79 -0
  52. package/lib/client/mixins/IAMMixin.d.ts +54 -0
  53. package/lib/client/mixins/IAMMixin.js +181 -0
  54. package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
  55. package/lib/client/mixins/RuntimesMixin.js +229 -0
  56. package/lib/client/mixins/SpacerMixin.d.ts +111 -0
  57. package/lib/client/mixins/SpacerMixin.js +340 -0
  58. package/lib/client/utils/mixins.d.ts +12 -0
  59. package/lib/{sdk/client → client}/utils/mixins.js +0 -28
  60. package/lib/client/utils/spacerUtils.d.ts +18 -0
  61. package/lib/client/utils/spacerUtils.js +32 -0
  62. package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
  63. package/lib/collaboration/DatalayerCollaboration.js +2 -2
  64. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
  65. package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
  66. package/lib/components/progress/CreditsIndicator.d.ts +1 -1
  67. package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
  68. package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
  69. package/lib/components/runtimes/RuntimeLauncherDialog.js +2 -2
  70. package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
  71. package/lib/components/runtimes/RuntimePickerBase.js +1 -1
  72. package/lib/components/runtimes/RuntimePickerCell.js +3 -3
  73. package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
  74. package/lib/components/runtimes/RuntimePickerNotebook.js +2 -2
  75. package/lib/components/runtimes/RuntimeTransfer.d.ts +2 -2
  76. package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
  77. package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
  78. package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
  79. package/lib/config/Configuration.d.ts +8 -0
  80. package/lib/hooks/useDatalayer.js +1 -1
  81. package/lib/hooks/useRuntimes.js +1 -1
  82. package/lib/hooks/useToast.js +1 -1
  83. package/lib/index.d.ts +2 -3
  84. package/lib/index.js +4 -3
  85. package/lib/models/Common.d.ts +64 -0
  86. package/lib/models/CreditsDTO.d.ts +124 -0
  87. package/lib/models/CreditsDTO.js +135 -0
  88. package/lib/models/Environment.d.ts +1 -1
  89. package/lib/models/EnvironmentDTO.d.ts +125 -0
  90. package/lib/models/EnvironmentDTO.js +88 -0
  91. package/lib/models/HealthCheck.d.ts +72 -0
  92. package/lib/models/HealthCheck.js +107 -0
  93. package/lib/{api/types/iam.d.ts → models/IAM.d.ts} +15 -78
  94. package/lib/models/ItemDTO.d.ts +74 -0
  95. package/lib/models/ItemDTO.js +186 -0
  96. package/lib/models/LexicalDTO.d.ts +155 -0
  97. package/lib/models/LexicalDTO.js +157 -0
  98. package/lib/models/NotebookDTO.d.ts +96 -0
  99. package/lib/models/NotebookDTO.js +153 -0
  100. package/lib/models/Profile.d.ts +65 -0
  101. package/lib/models/RuntimeDTO.d.ts +191 -0
  102. package/lib/models/RuntimeDTO.js +204 -0
  103. package/lib/models/RuntimeSnapshotDTO.d.ts +173 -0
  104. package/lib/models/RuntimeSnapshotDTO.js +139 -0
  105. package/lib/models/SpaceDTO.d.ts +280 -0
  106. package/lib/models/SpaceDTO.js +239 -0
  107. package/lib/models/UserDTO.d.ts +86 -0
  108. package/lib/models/UserDTO.js +84 -0
  109. package/lib/models/index.d.ts +45 -4
  110. package/lib/models/index.js +45 -4
  111. package/lib/sdk/index.d.ts +5 -4
  112. package/lib/sdk/index.js +6 -5
  113. package/lib/services/DatalayerServiceManager.js +1 -1
  114. package/lib/state/substates/CoreState.js +2 -0
  115. package/lib/state/substates/RuntimesState.d.ts +1 -1
  116. package/lib/state/substates/RuntimesState.js +1 -1
  117. package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
  118. package/lib/{sdk/stateful → stateful}/index.js +1 -1
  119. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
  120. package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
  121. package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
  122. package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
  123. package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
  124. package/package.json +13 -10
  125. package/lib/__tests__/hooks.test.d.ts +0 -1
  126. package/lib/__tests__/hooks.test.js +0 -19
  127. package/lib/__tests__/index.test.d.ts +0 -1
  128. package/lib/__tests__/index.test.js +0 -27
  129. package/lib/__tests__/integration.test.d.ts +0 -1
  130. package/lib/__tests__/integration.test.js +0 -57
  131. package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
  132. package/lib/__tests__/shared/cleanup-shared.js +0 -228
  133. package/lib/__tests__/shared/test-config.d.ts +0 -51
  134. package/lib/__tests__/shared/test-config.js +0 -110
  135. package/lib/__tests__/shared/test-constants.d.ts +0 -66
  136. package/lib/__tests__/shared/test-constants.js +0 -79
  137. package/lib/__tests__/utils.test.d.ts +0 -1
  138. package/lib/__tests__/utils.test.js +0 -59
  139. package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
  140. package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
  141. package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
  142. package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
  143. package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
  144. package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
  145. package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
  146. package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
  147. package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
  148. package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
  149. package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
  150. package/lib/api/__tests__/runtimes.integration.test.js +0 -369
  151. package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
  152. package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
  153. package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
  154. package/lib/api/__tests__/spacer.integration.test.js +0 -519
  155. package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
  156. package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
  157. package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
  158. package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
  159. package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
  160. package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
  161. package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
  162. package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
  163. package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
  164. package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
  165. package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
  166. package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
  167. package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
  168. package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
  169. package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
  170. package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
  171. package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
  172. package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
  173. package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
  174. package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
  175. package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
  176. package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
  177. package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
  178. package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
  179. package/lib/api/types/index.d.ts +0 -32
  180. package/lib/api/types/index.js +0 -36
  181. package/lib/api/types/runtimes.d.ts +0 -235
  182. package/lib/api/types/spacer.d.ts +0 -271
  183. package/lib/api/types/spacer.js +0 -5
  184. package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
  185. package/lib/api/utils/__tests__/validation.test.js +0 -109
  186. package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
  187. package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
  188. package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
  189. package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
  190. package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
  191. package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
  192. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
  193. package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
  194. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
  195. package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
  196. package/lib/sdk/client/base.d.ts +0 -88
  197. package/lib/sdk/client/base.js +0 -112
  198. package/lib/sdk/client/index.d.ts +0 -192
  199. package/lib/sdk/client/index.js +0 -128
  200. package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
  201. package/lib/sdk/client/mixins/HealthMixin.js +0 -133
  202. package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
  203. package/lib/sdk/client/mixins/IAMMixin.js +0 -83
  204. package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
  205. package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
  206. package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
  207. package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
  208. package/lib/sdk/client/models/Lexical.d.ts +0 -156
  209. package/lib/sdk/client/models/Lexical.js +0 -275
  210. package/lib/sdk/client/models/Notebook.d.ts +0 -174
  211. package/lib/sdk/client/models/Notebook.js +0 -311
  212. package/lib/sdk/client/models/Runtime.d.ts +0 -221
  213. package/lib/sdk/client/models/Runtime.js +0 -341
  214. package/lib/sdk/client/models/Snapshot.d.ts +0 -156
  215. package/lib/sdk/client/models/Snapshot.js +0 -244
  216. package/lib/sdk/client/models/Space.d.ts +0 -182
  217. package/lib/sdk/client/models/Space.js +0 -276
  218. package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
  219. package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
  220. package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
  221. package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
  222. package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
  223. package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
  224. package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
  225. package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
  226. package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
  227. package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
  228. package/lib/sdk/client/models/index.d.ts +0 -30
  229. package/lib/sdk/client/models/index.js +0 -30
  230. package/lib/sdk/client/utils/mixins.d.ts +0 -42
  231. /package/lib/{api/types/iam.js → models/Common.js} +0 -0
  232. /package/lib/{api/types/runtimes.js → models/IAM.js} +0 -0
  233. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
  234. /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
  235. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
  236. /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
  237. /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
  238. /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
  239. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
  240. /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
  241. /package/lib/{sdk/stateful → stateful}/runtimes/apis.js +0 -0
  242. /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
  243. /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
  244. /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
  245. /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
  246. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
  247. /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
  248. /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
  249. /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
@@ -1,122 +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 } from 'vitest';
6
- import { environments } from '../runtimes';
7
- import { testConfig, debugLog, skipIfNoToken, } from '../../__tests__/shared/test-config';
8
- let DATALAYER_TOKEN;
9
- let BASE_URL;
10
- // Skip all tests if no token is available
11
- const skipTests = skipIfNoToken();
12
- beforeAll(async () => {
13
- if (skipTests) {
14
- console.log('WARNING: Skipping Runtimes Environments integration tests: No Datalayer API token configured');
15
- console.log(' Set DATALAYER_API_TOKEN env var or DATALAYER_TEST_TOKEN in .env.test');
16
- return;
17
- }
18
- // Get token and base URL from test config
19
- DATALAYER_TOKEN = testConfig.getToken();
20
- BASE_URL = testConfig.getBaseUrl('RUNTIMES');
21
- debugLog('Test configuration loaded');
22
- debugLog('Base URL:', BASE_URL);
23
- debugLog('Token available:', !!DATALAYER_TOKEN);
24
- });
25
- describe.skipIf(skipTests)('Runtimes Environments Integration Tests', () => {
26
- describe('list', () => {
27
- it('should successfully list available environments', async () => {
28
- console.log('Testing list environments endpoint...');
29
- const response = await environments.listEnvironments(DATALAYER_TOKEN, BASE_URL);
30
- console.log('Environments response:', JSON.stringify(response, null, 2));
31
- // Verify the response structure
32
- expect(response).toBeDefined();
33
- expect(response).toHaveProperty('success');
34
- expect(response.success).toBe(true);
35
- expect(response).toHaveProperty('message');
36
- expect(response).toHaveProperty('environments');
37
- expect(Array.isArray(response.environments)).toBe(true);
38
- // Check that we have at least some environments
39
- console.log(`Found ${response.environments.length} available environments`);
40
- // If we have environments, check the structure of the first one
41
- if (response.environments.length > 0) {
42
- const firstEnv = response.environments[0];
43
- console.log('First environment:', firstEnv.title);
44
- // Verify environment structure
45
- expect(firstEnv).toHaveProperty('title');
46
- expect(firstEnv).toHaveProperty('description');
47
- expect(firstEnv).toHaveProperty('dockerImage');
48
- expect(firstEnv).toHaveProperty('language');
49
- expect(firstEnv).toHaveProperty('burning_rate');
50
- expect(typeof firstEnv.burning_rate).toBe('number');
51
- }
52
- });
53
- it('should work with default URL if not specified', async () => {
54
- console.log('Testing list environments with default URL...');
55
- // Call without specifying URL to use default
56
- const response = await environments.listEnvironments(DATALAYER_TOKEN);
57
- console.log('Default URL environments response:', JSON.stringify(response, null, 2));
58
- // Should still get valid response
59
- expect(response).toBeDefined();
60
- expect(response.success).toBe(true);
61
- expect(response).toHaveProperty('environments');
62
- expect(Array.isArray(response.environments)).toBe(true);
63
- });
64
- it('should include environment resource information', async () => {
65
- console.log('Testing environment resource information...');
66
- const response = await environments.listEnvironments(DATALAYER_TOKEN, BASE_URL);
67
- // Check if any environment has resource information
68
- const envWithResources = response.environments.find(env => env.resources || env.resourcesRanges);
69
- if (envWithResources) {
70
- console.log('Found environment with resources:', envWithResources.title);
71
- if (envWithResources.resources) {
72
- console.log('Resources:', envWithResources.resources);
73
- expect(envWithResources.resources).toHaveProperty('cpu');
74
- expect(envWithResources.resources).toHaveProperty('memory');
75
- }
76
- if (envWithResources.resourcesRanges) {
77
- console.log('Resource ranges:', envWithResources.resourcesRanges);
78
- }
79
- }
80
- else {
81
- console.log('No environments with explicit resource information found');
82
- }
83
- });
84
- it('should include environment snippets if available', async () => {
85
- console.log('Testing environment snippets...');
86
- const response = await environments.listEnvironments(DATALAYER_TOKEN, BASE_URL);
87
- // Check if any environment has snippets
88
- const envWithSnippets = response.environments.find(env => env.snippets && env.snippets.length > 0);
89
- if (envWithSnippets) {
90
- console.log('Found environment with snippets:', envWithSnippets.title);
91
- console.log('Number of snippets:', envWithSnippets.snippets?.length);
92
- const firstSnippet = envWithSnippets.snippets[0];
93
- expect(firstSnippet).toHaveProperty('title');
94
- // Description might be optional
95
- if (firstSnippet.description) {
96
- expect(firstSnippet).toHaveProperty('description');
97
- }
98
- expect(firstSnippet).toHaveProperty('code');
99
- }
100
- else {
101
- console.log('No environments with snippets found');
102
- }
103
- });
104
- });
105
- describe('error handling', () => {
106
- it('should handle invalid token gracefully', async () => {
107
- console.log('Testing with invalid token...');
108
- const invalidToken = 'invalid-token-123';
109
- try {
110
- await environments.listEnvironments(invalidToken, BASE_URL);
111
- // If we get here, the API accepted the invalid token (shouldn't happen)
112
- console.log('WARNING: API accepted invalid token');
113
- }
114
- catch (error) {
115
- console.log('Error with invalid token:', error.message);
116
- // We expect an error with invalid token
117
- expect(error).toBeDefined();
118
- expect(error.message).toBeDefined();
119
- }
120
- });
121
- });
122
- });
@@ -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 '../runtimes';
7
- import { testConfig, skipIfNoToken } from '../../__tests__/shared/test-config';
8
- /**
9
- * Integration tests for Runtimes health check API
10
- * These tests run against the actual Datalayer Runtimes API
11
- */
12
- describe('Runtimes Healthz Integration Tests', () => {
13
- describe.skipIf(skipIfNoToken())('ping endpoint', () => {
14
- it('should successfully ping the Runtimes service', async () => {
15
- console.log('Testing health check ping endpoint for Runtimes...');
16
- const response = await healthz.ping(testConfig.getBaseUrl('RUNTIMES'));
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('Runtimes 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 Runtimes 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 {};
@@ -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,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 {};