Skip to content

Commit

Permalink
chore: Merge development
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoud-Emad committed Jun 6, 2024
1 parent da3fe2a commit b1390a2
Show file tree
Hide file tree
Showing 235 changed files with 9,049 additions and 2,173 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/grid_client_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
id: kubernetes
continue-on-error: true
run: |
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/kubernetes.ts
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/orchestrators/kubernetes_leader.ts
- name: Run test vm with qsfs
id: vmqsfs
continue-on-error: true
Expand All @@ -76,7 +76,7 @@ jobs:
id: kubernetesqsfs
continue-on-error: true
run: |
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/kubernetes_with_qsfs.ts
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/orchestrators/kubernetes_with_qsfs.ts
- name: Run test kvstore
id: kvstore
continue-on-error: true
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/playground_selenium.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Playground Selenium Tests

on:
workflow_dispatch:
schedule:
- cron: "0 6 * * *"

jobs:
selenium-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setting up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Installing all necessary packages
run: pip install -r packages/playground/tests/frontend_selenium/requirements.txt
- name: Node install
uses: actions/setup-node@v4
with:
node-version: 18
- name: Yarn install
run: yarn install
- name: Lerna Build
run: yarn lerna run build
- name: Yarn Serve
run: make run project=playground &
- name: Wait for localhost
run: sleep 60
- name: Run tests
working-directory: ./packages/playground/tests/frontend_selenium
env:
TFCHAIN_MNEMONICS: ${{ secrets.TFCHAIN_MNEMONICS }}
TFCHAIN_NODE_MNEMONICS: ${{ secrets.TFCHAIN_NODE_MNEMONICS }}
STELLAR_ADDRESS: ${{ secrets.STELLAR_ADDRESS }}
EMAIL: ${{ secrets.EMAIL }}
run: python -m pytest -v
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "2.4.1",
"version": "2.5.0-rc1",
"npmClient": "yarn"
}
2 changes: 1 addition & 1 deletion packages/UI/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@threefold/ui",
"version": "2.4.1",
"version": "2.5.0-rc1",
"private": false,
"main": "dist/threefold-ui.umd.js",
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql_client/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@threefold/graphql_client",
"version": "2.4.1",
"version": "2.5.0-rc1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"scripts": {
"build": "tsc"
},
"dependencies": {
"@threefold/types": "^2.4.1",
"@threefold/types": "^2.5.0-rc1",
"ts-mixer": "^6.0.2"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/grid_client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@threefold/grid_client",
"author": "Ahmed Hanafy",
"version": "2.4.1",
"version": "2.5.0-rc1",
"license": "ISC",
"homepage": "https://github.com/threefoldtech/tfgrid-sdk-ts/tree/development/packages/grid_client/README.md",
"repository": {
Expand All @@ -14,9 +14,9 @@
"dependencies": {
"@jimber/pkid": "1.0.4",
"@noble/secp256k1": "^1.7.1",
"@threefold/rmb_direct_client": "^2.4.1",
"@threefold/tfchain_client": "^2.4.1",
"@threefold/types": "^2.4.1",
"@threefold/rmb_direct_client": "^2.5.0-rc1",
"@threefold/tfchain_client": "^2.5.0-rc1",
"@threefold/types": "^2.5.0-rc1",
"algosdk": "^1.19.0",
"appdata-path": "^1.0.0",
"await-lock": "^2.2.2",
Expand Down
93 changes: 93 additions & 0 deletions packages/grid_client/scripts/applications/algorand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { FilterOptions, MachinesModel } from "../../src";
import { config, getClient } from "../client_loader";
import { log, pingNodes } from "../utils";

async function deploy(client, vms) {
const resultVM = await client.machines.deploy(vms);
log("================= Deploying VM =================");
log(resultVM);
log("================= Deploying VM =================");
}

async function getDeployment(client, vms) {
const resultVM = await client.machines.getObj(vms.name);
log("================= Getting deployment information =================");
log(resultVM);
log("================= Getting deployment information =================");
}

async function cancel(client, vms) {

Check warning on line 19 in packages/grid_client/scripts/applications/algorand.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'cancel' is defined but never used
const resultVM = await client.machines.delete(vms);
log("================= Canceling the deployment =================");
log(resultVM);
log("================= Canceling the deployment =================");
}

async function main() {
const name = "newalgorand";
const grid3 = await getClient(`algorand/${name}`);
const instanceCapacity = { cru: 2, mru: 4, sru: 100 }; // Update the instance capacity values according to your requirements.

//VMNode Selection
const vmQueryOptions: FilterOptions = {
cru: instanceCapacity.cru,
mru: instanceCapacity.mru,
sru: instanceCapacity.sru,
availableFor: grid3.twinId,
farmId: 1,
};
const nodes = await grid3.capacity.filterNodes(vmQueryOptions);
const vmNode = await pingNodes(grid3, nodes);

const vms: MachinesModel = {
name,
network: {
name: "wedtest",
ip_range: "10.249.0.0/16",
},
machines: [
{
name: "algorand",
node_id: vmNode,
disks: [
{
name: "docker",
size: instanceCapacity.sru,
mountpoint: "/var/lib/docker",
},
],
planetary: true,
public_ip: false,
public_ip6: false,
mycelium: false,
cpu: instanceCapacity.cru,
memory: 1024 * instanceCapacity.mru,
rootfs_size: 0,
flist: "https://hub.grid.tf/tf-official-apps/algorand-latest.flist",
entrypoint: "/sbin/zinit init",
env: {
SSH_KEY: config.ssh_key,
// Select a network to work against.
NETWORK: "mainnet",
// Default, Relay, Indexer
NODE_TYPE: "default",
},
},
],
metadata: "",
description: "test deploying Algorand via ts grid3 client",
};

//Deploy VMs
await deploy(grid3, vms);

//Get the deployment
await getDeployment(grid3, vms);

//Uncomment the line below to cancel the deployment
// await cancel(grid3, { name });

await grid3.disconnect();
}

main();
117 changes: 117 additions & 0 deletions packages/grid_client/scripts/applications/casberlabs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { FilterOptions, GatewayNameModel, MachinesModel } from "../../src";
import { config, getClient } from "../client_loader";
import { log, pingNodes } from "../utils";

async function deploy(client, vms, subdomain, gatewayNode) {
const resultVM = await client.machines.deploy(vms);
log("================= Deploying VM =================");
log(resultVM);
log("================= Deploying VM =================");

const vmPlanetary = (await client.machines.getObj(vms.name))[0].planetary;
//Name Gateway Model
const gw: GatewayNameModel = {
name: subdomain,
node_id: gatewayNode.nodeId,
tls_passthrough: false,
backends: ["http://[" + vmPlanetary + "]:80"],
};

const resultGateway = await client.gateway.deploy_name(gw);
log("================= Deploying name gateway =================");
log(resultGateway);
log("================= Deploying name gateway =================");
}

async function getDeployment(client, vms, gw) {
const resultVM = await client.machines.getObj(vms.name);
const resultGateway = await client.gateway.getObj(gw);
log("================= Getting deployment information =================");
log(resultVM);
log(resultGateway);
log("https://" + resultGateway[0].domain);
log("================= Getting deployment information =================");
}

async function cancel(client, vms, gw) {

Check warning on line 36 in packages/grid_client/scripts/applications/casberlabs.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'cancel' is defined but never used
const resultVM = await client.machines.delete(vms);
const resultGateway = await client.gateway.delete_name(gw);
log("================= Canceling the deployment =================");
log(resultVM);
log(resultGateway);
log("================= Canceling the deployment =================");
}

async function main() {
const name = "newcasperlabs";
const grid3 = await getClient(`casperlabs/${name}`);
const subdomain = "cl" + grid3.twinId + name;
const instanceCapacity = { cru: 2, mru: 4, sru: 100 }; // Update the instance capacity values according to your requirements.

//VMNode Selection
const vmQueryOptions: FilterOptions = {
cru: instanceCapacity.cru,
mru: instanceCapacity.mru,
sru: instanceCapacity.sru,
availableFor: grid3.twinId,
farmId: 1,
};
//GatewayNode Selection
const gatewayQueryOptions: FilterOptions = {
gateway: true,
availableFor: grid3.twinId,
};
const gatewayNode = (await grid3.capacity.filterNodes(gatewayQueryOptions))[0];
const nodes = await grid3.capacity.filterNodes(vmQueryOptions);
const vmNode = await pingNodes(grid3, nodes);
const domain = subdomain + "." + gatewayNode.publicConfig.domain;

const vms: MachinesModel = {
name,
network: {
name: "wedtest",
ip_range: "10.249.0.0/16",
},
machines: [
{
name: "casperlabs",
node_id: vmNode,
disks: [
{
name: "wedDisk",
size: instanceCapacity.sru,
mountpoint: "/data",
},
],
planetary: true,
public_ip: false,
public_ip6: false,
mycelium: false,
cpu: instanceCapacity.cru,
memory: 1024 * instanceCapacity.mru,
rootfs_size: 0,
flist: "https://hub.grid.tf/tf-official-apps/casperlabs-latest.flist",
entrypoint: "/sbin/zinit init",
env: {
SSH_KEY: config.ssh_key,
CASPERLABS_HOSTNAME: domain,
},
},
],
metadata: "",
description: "test deploying CasberLabs via ts grid3 client",
};

//Deploy VMs
await deploy(grid3, vms, subdomain, gatewayNode);

//Get the deployment
await getDeployment(grid3, vms, subdomain);

//Uncomment the line below to cancel the deployment
// await cancel(grid3, { name }, { name: subdomain });

await grid3.disconnect();
}

main();
Loading

0 comments on commit b1390a2

Please sign in to comment.