Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 71 additions & 22 deletions tests/smoketests/blueprints.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { BlueprintView } from '@runloop/api-client/resources/blueprints';
import { makeClient, THIRTY_SECOND_TIMEOUT, uniqueName } from './utils';
import { DevboxView } from '@runloop/api-client/resources/devboxes';

const client = makeClient();

Expand Down Expand Up @@ -34,35 +36,82 @@ describe('smoketest: blueprints', () => {
test(
'start devbox from base blueprint by ID',
async () => {
const devbox = await client.devboxes.createAndAwaitRunning(
{
blueprint_id: blueprintId!,
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
},
{
polling: { maxAttempts: 120, pollingIntervalMs: 5_000, timeoutMs: 20 * 60 * 1000 },
},
);
expect(devbox.blueprint_id).toBe(blueprintId);
await client.devboxes.shutdown(devbox.id);
let devbox: DevboxView | undefined;
try {
devbox = await client.devboxes.createAndAwaitRunning(
{
blueprint_id: blueprintId!,
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
},
{
polling: { maxAttempts: 120, pollingIntervalMs: 5_000, timeoutMs: 20 * 60 * 1000 },
},
);
expect(devbox.blueprint_id).toBe(blueprintId);
} finally {
if (devbox) {
await client.devboxes.shutdown(devbox.id);
}
}
},
THIRTY_SECOND_TIMEOUT,
);

test(
'start devbox from base blueprint by Name',
async () => {
const devbox = await client.devboxes.createAndAwaitRunning(
{
blueprint_name: blueprintName,
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
},
{
polling: { maxAttempts: 120, pollingIntervalMs: 5_000, timeoutMs: 20 * 60 * 1000 },
},
);
expect(devbox.blueprint_id).toBeTruthy();
await client.devboxes.shutdown(devbox.id);
let devbox: DevboxView | undefined;
try {
devbox = await client.devboxes.createAndAwaitRunning(
{
blueprint_name: blueprintName,
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
},
{
polling: { maxAttempts: 120, pollingIntervalMs: 5_000, timeoutMs: 20 * 60 * 1000 },
},
);
expect(devbox.blueprint_id).toBeTruthy();
} finally {
if (devbox) {
await client.devboxes.shutdown(devbox.id);
}
}
},
THIRTY_SECOND_TIMEOUT,
);
});

// Only run secrets test in CI where the secret is available
(process.env['RUN_SMOKETESTS'] ? describe : describe.skip)('blueprint secrets', () => {
const secretsBlueprintName = uniqueName('bp-secrets');

test(
'create blueprint with secret in Dockerfile and await build',
async () => {
let bpt: BlueprintView | undefined;
try {
bpt = await client.blueprints.createAndAwaitBuildCompleted(
{
name: secretsBlueprintName,
dockerfile:
'FROM runloop:runloop/starter-arm64\nARG GITHUB_TOKEN\nRUN git config --global credential.helper \'!f() { echo "username=x-access-token"; echo "password=$GITHUB_TOKEN"; }; f\' && git clone https://github.com/runloopai/runloop-fe.git /workspace/runloop-fe && git config --global --unset credential.helper\nWORKDIR /workspace/runloop-fe',
secrets: {
GITHUB_TOKEN: 'GITHUB_TOKEN_FOR_SMOKETESTS',
},
},
{
polling: { maxAttempts: 180, pollingIntervalMs: 5_000, timeoutMs: 30 * 60 * 1000 },
},
);

expect(bpt.status).toBe('build_complete');
expect(bpt.parameters.secrets?.['GITHUB_TOKEN']).toBe('GITHUB_TOKEN_FOR_SMOKETESTS');
} finally {
if (bpt) {
await client.blueprints.delete(bpt.id);
}
}
},
THIRTY_SECOND_TIMEOUT,
);
Expand Down
19 changes: 13 additions & 6 deletions tests/smoketests/devboxes.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DevboxView } from '@runloop/api-client/resources/devboxes';
import { makeClient, THIRTY_SECOND_TIMEOUT, uniqueName } from './utils';

const client = makeClient();
Expand All @@ -18,12 +19,18 @@ describe('smoketest: devboxes', () => {
test(
'create devbox',
async () => {
const created = await client.devboxes.create({
name: uniqueName('smoke-devbox'),
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
});
expect(created?.id).toBeTruthy();
await client.devboxes.shutdown(created.id);
let devbox: DevboxView | undefined;
try {
devbox = await client.devboxes.create({
name: uniqueName('smoke-devbox'),
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
});
expect(devbox?.id).toBeTruthy();
} finally {
if (devbox) {
await client.devboxes.shutdown(devbox.id);
}
}
},
THIRTY_SECOND_TIMEOUT,
);
Expand Down
52 changes: 30 additions & 22 deletions tests/smoketests/object-oriented/blueprint.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RunloopSDK } from '@runloop/api-client';
import { makeClient, THIRTY_SECOND_TIMEOUT, uniqueName } from '../utils';
import { Blueprint } from '@runloop/api-client/objects';
import { Blueprint, Devbox } from '@runloop/api-client/objects';

const client = makeClient();
const sdk = new RunloopSDK({
Expand Down Expand Up @@ -67,15 +67,19 @@ describe('smoketest: object-oriented blueprint', () => {
test('create devbox from blueprint (instance method)', async () => {
expect(blueprint).toBeDefined();
// Use blueprint instance method to create devbox
const devbox = await blueprint.createDevbox({
name: uniqueName('devbox-from-blueprint-instance'),
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
});
expect(devbox).toBeDefined();
expect(devbox.id).toBeTruthy();

// Clean up the devbox
await devbox.shutdown();
let devbox: Devbox | undefined;
try {
devbox = await blueprint.createDevbox({
name: uniqueName('devbox-from-blueprint-instance'),
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
});
expect(devbox).toBeDefined();
expect(devbox.id).toBeTruthy();
} finally {
if (devbox) {
await devbox.shutdown();
}
}
});

test('delete blueprint', async () => {
Expand All @@ -100,18 +104,22 @@ describe('smoketest: object-oriented blueprint', () => {

test('get blueprint by ID', async () => {
// First create a blueprint
const blueprint = await sdk.blueprint.create({
name: uniqueName('sdk-blueprint-retrieve'),
dockerfile: 'FROM ubuntu:20.04',
});
expect(blueprint.id).toBeTruthy();

// Retrieve it by ID
const retrieved = await sdk.blueprint.fromId(blueprint.id);
expect(retrieved.id).toBe(blueprint.id);

// Clean up
await blueprint.delete();
let blueprint: Blueprint | undefined;
try {
blueprint = await sdk.blueprint.create({
name: uniqueName('sdk-blueprint-retrieve'),
dockerfile: 'FROM ubuntu:20.04',
});
expect(blueprint?.id).toBeTruthy();

// Retrieve it byID
const retrieved = sdk.blueprint.fromId(blueprint.id);
expect(retrieved.id).toBe(blueprint.id);
} finally {
if (blueprint) {
await blueprint.delete();
}
}
});
});
});
27 changes: 16 additions & 11 deletions tests/smoketests/object-oriented/devbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,24 @@ describe('smoketest: object-oriented devbox', () => {
});

test('get devbox by ID', async () => {
// First create a devbox
const devbox = await sdk.devbox.create({
name: uniqueName('sdk-devbox-retrieve'),
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
});
expect(devbox.id).toBeTruthy();
let devbox: Devbox | undefined;
try {
devbox = await sdk.devbox.create({
name: uniqueName('sdk-devbox-retrieve'),
launch_parameters: { resource_size_request: 'X_SMALL', keep_alive_time_seconds: 60 * 5 }, // 5 minutes
});
expect(devbox.id).toBeTruthy();

// Retrieve it by ID
const retrieved = await sdk.devbox.fromId(devbox.id);
expect(retrieved.id).toBe(devbox.id);
// Retrieve it by ID
const retrieved = sdk.devbox.fromId(devbox.id);
expect(retrieved.id).toBe(devbox.id);

// Clean up
await devbox.shutdown();
// Clean up
} finally {
if (devbox) {
await devbox.shutdown();
}
}
});
});

Expand Down
Loading
Loading