Skip to content

Commit

Permalink
Merge branch 'development' into development_add_storing_arch_decision
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedElmdary committed Nov 16, 2023
2 parents 6148c16 + 704e339 commit b6d3069
Show file tree
Hide file tree
Showing 76 changed files with 1,296 additions and 393 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/grid_client_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:
gpg --export 569130E8CA20FBC4CB3FDE555898470A764B32C9 | sudo apt-key add -
echo 'deb http://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/ debian yggdrasil' | sudo tee /etc/apt/sources.list.d/yggdrasil.list
sudo apt-get update
sudo apt-get install yggdrasil
wget https://github.com/yggdrasil-network/yggdrasil-go/releases/download/v0.4.7/yggdrasil-0.4.7-amd64.deb
sudo dpkg -i yggdrasil-0.4.7-amd64.deb
sudo systemctl enable yggdrasil
PEERS=$(curl https://raw.githubusercontent.com/threefoldtech/zos-config/main/development.json | jq '.yggdrasil.peers[]' -r | sed 's/\//\\\//g' | sed -z 's/\n/\\n/g')
sudo sed -i -- 's/Peers\: \[\]/Peers: [\n'"$PEERS"']/g' /etc/yggdrasil.conf
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/mass_deployments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Mass Deployments

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

jobs:
mass-deployments:
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
NETWORK: main
RMB_PROXY: true
STORE_SECRET: secret
MNEMONIC: ${{ secrets.MNEMONIC }}
SSH_KEY: ${{ secrets.SSH_KEY }}

steps:
- uses: actions/checkout@v4
- name: Set up node 18
uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"

- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y git libtool tmux redis net-tools
- name: Install
run: |
yarn
lerna run build --no-private
- name: Run test mass deployments
id: massdeployments
continue-on-error: true
run: |
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/mass_deployments.ts
- name: Cleanup - Delete all contracts
id: deleteall
run: |
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/delete_all_contracts.ts
- name: Test Results
run: |
echo Batch Vms: ${{ steps.massdeployments.outcome }}
echo Delete all contracts: ${{ steps.deleteall.outcome }}
- name: Check test script status
if: |
steps.massdeployments.outcome != 'success'
run: exit 1
6 changes: 2 additions & 4 deletions .github/workflows/weblets_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: ["18.16.0"]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -36,9 +36,7 @@ jobs:
- name: Install dependencies
run: |
yarn install
cd packages/weblets
yarn install
cd playground
cd packages/weblets/playground
yarn install
- name: Build
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/weblets_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: ["18.16.0"]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -38,9 +38,7 @@ jobs:
- name: Install dependencies
run: |
yarn install
cd packages/weblets
yarn install
cd playground
cd packages/weblets/playground
yarn install
- name: Build in case development
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weblets_cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: ["18.16.0"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
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.1.1",
"version": "2.2.0-rc4",
"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": "0.0.1",
"version": "2.2.0-rc4",
"private": true,
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/charts/tfgrid-dashboard/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ version: 1.0.6
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v2.1.1"
appVersion: "v2.2.0-rc4"
2 changes: 1 addition & 1 deletion packages/dashboard/charts/tfgrid-dashboard/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ replicaCount: 1
image:
repository: ghcr.io/threefoldtech/dashboard
pullPolicy: Always
tag: "2.1.1"
tag: "2.2.0-rc4"

env:
- name: "STELLAR_NETWORK"
Expand Down
6 changes: 3 additions & 3 deletions packages/dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@threefold/dashboard",
"version": "2.1.1",
"version": "2.2.0-rc4",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand All @@ -19,8 +19,8 @@
"@polkadot/extension-dapp": "0.45.1",
"@polkadot/ui-keyring": "^2.2.1",
"@popperjs/core": "^2.11.5",
"@threefold/grid_client": "^2.1.1",
"@threefold/tfchain_client": "^2.1.1",
"@threefold/grid_client": "^2.2.0-rc4",
"@threefold/tfchain_client": "^2.2.0-rc4",
"@types/ip": "^1.1.0",
"@types/md5": "^2.3.2",
"apollo-cache-inmemory": "^1.6.6",
Expand Down
6 changes: 3 additions & 3 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.1.1",
"version": "2.2.0-rc4",
"license": "ISC",
"homepage": "https://github.com/threefoldtech/tfgrid-sdk-ts/tree/development/packages/grid_client/README.md",
"repository": {
Expand All @@ -14,8 +14,8 @@
"dependencies": {
"@jimber/pkid": "1.0.4",
"@noble/secp256k1": "^1.7.1",
"@threefold/rmb_direct_client": "^2.1.1",
"@threefold/tfchain_client": "^2.1.1",
"@threefold/rmb_direct_client": "^2.2.0-rc4",
"@threefold/tfchain_client": "^2.2.0-rc4",
"algosdk": "^1.19.0",
"appdata-path": "^1.0.0",
"axios": "^0.27.2",
Expand Down
120 changes: 120 additions & 0 deletions packages/grid_client/scripts/mass_deployments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import {
DiskModel,
FarmFilterOptions,
FilterOptions,
generateString,
MachineModel,
MachinesModel,
NetworkModel,
randomChoice,
} from "../src";
import { config, getClient } from "./client_loader";
import { log } from "./utils";

async function main() {
const grid3 = await getClient();

const errors: any = [];
let failedCount = 0;
let successCount = 0;

for (let i = 0; i < 100; i++) {
//Generating the resources
const cru = 1;
const mru = 256;
const diskSize = 5;
const rootFs = 1;
const vmName = "vm" + generateString(8);
const deploymentName = "dep" + generateString(8);
const publicIp = false;

// create network Object
const n = new NetworkModel();
n.name = "nw" + generateString(5);
n.ip_range = "10.238.0.0/16";

// create disk Object
const disk1 = new DiskModel();
disk1.name = "d" + generateString(5);
disk1.size = diskSize;
disk1.mountpoint = "/newDisk1";

//Farm Selection
const farms = await grid3.capacity.filterFarms({
nodeMRU: mru / 1024,
nodeSRU: diskSize + rootFs,
publicIp: publicIp,
availableFor: await grid3.twins.get_my_twin_id(),
randomize: true,
} as FarmFilterOptions);

if (farms.length < 1) {
throw new Error("No farms found");
}

//Node Selection
const nodes = await grid3.capacity.filterNodes({
cru: cru,
mru: mru / 1024,
sru: rootFs + diskSize,
availableFor: await grid3.twins.get_my_twin_id(),
farmId: +randomChoice(farms).farmId,
randomize: true,
} as FilterOptions);

if (nodes.length < 1) {
errors.push("Node not found");
failedCount++;
continue;
}

// create vm node Object
const vm = new MachineModel();
vm.name = vmName;
vm.node_id = nodes[0].nodeId;
vm.disks = [disk1];
vm.public_ip = publicIp;
vm.planetary = true;
vm.cpu = cru;
vm.memory = mru;
vm.rootfs_size = rootFs;
vm.flist = "https://hub.grid.tf/tf-official-apps/base:latest.flist";
vm.entrypoint = "/sbin/zinit init";
vm.env = {
SSH_KEY: config.ssh_key,
};

// create VMs Object
const vms = new MachinesModel();
vms.name = deploymentName;
vms.network = n;
vms.machines = [vm];
vms.metadata = "";
vms.description = "test deploying VMs via ts grid3 client";

// deploy vm
try {
await grid3.machines.deploy(vms);
successCount++;
} catch (error) {
log(error);
errors.push(error);
failedCount++;
continue;
}
}

log("Successful Deployments: " + successCount);
log("Failed Deployments: " + failedCount);

// List of failed deployments errors
log("Failed deployments errors: ");
for (let i = 0; i < errors.length; i++) {
log(errors[i]);
log("---------------------------------------------");
}

await grid3.disconnect();
}

main();
2 changes: 1 addition & 1 deletion packages/grid_client/src/clients/rmb/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class RMB {
this.client = rmbClient;
}

async request(destTwinIds: number[], cmd: string, payload: string, expiration = 60, retires = 1) {
async request(destTwinIds: number[], cmd: string, payload: string, expiration = 10, retires = 1) {
let result;
try {
const requestId = await this.client.send(cmd, payload, destTwinIds[0], expiration / 60);
Expand Down
Loading

0 comments on commit b6d3069

Please sign in to comment.