Skip to content

Commit 4b97c45

Browse files
GridClient Nightly ZOS3 Lite Mycelium test and update (#4047)
* Replace ZOS4 VM script with ZOS3 Lite Mycelium test and update nightly workflow * fix workflow * add muliple vm for zos 3 lite scripts and nightly * adding multiple tests result * adding zos3gateway script * adding domain to nightly fixing changes to make domain script work fine * Fix zos3lite gateway test * adding random name generation to multiple vms scripts * using the name generation from playground * fixing genrating string functions
1 parent 1d37ee1 commit 4b97c45

File tree

6 files changed

+246
-16
lines changed

6 files changed

+246
-16
lines changed

.github/workflows/grid_client_nightly.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,30 @@ jobs:
6262
run: |
6363
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/dynamic_single_vm.ts
6464
65+
- name: Run test Zos 3 lite gateway
66+
id: zos3lite_gateway_domain
67+
if: always()
68+
run: |
69+
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/zos3lite_gateway_domain.ts
70+
71+
- name: Run test single ZOS3 lite vm with mycelium
72+
id: zos3lite
73+
if: always()
74+
run: |
75+
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/single_vm_zos3_lite.ts
76+
6577
- name: Run test multiple vms
6678
id: multiple_vm
6779
if: always()
6880
run: |
6981
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/multiple_vms.ts
7082
83+
- name: Run test multiple zos3 lite vms
84+
id: multiple_zos3_lite_vm
85+
if: always()
86+
run: |
87+
yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/multiple_vms_zos_3_lite.ts
88+
7189
- name: Run test kubernetes
7290
id: k8s
7391
if: always()
@@ -145,7 +163,10 @@ jobs:
145163
> **Details on failed run**: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
146164
147165
- **Dynamic Single Vm**: ${{ steps.single_vm.outcome }}
166+
- **ZOS3 Lite Mycelium**: ${{ steps.zos3lite.outcome }}
148167
- **Multiple Vm**: ${{ steps.multiple_vm.outcome }}
168+
- **Multiple Vm zos3 lite**: ${{ steps.multiple_zos3_lite_vm.outcome }}
169+
- **zos3 lite gateway**: ${{ steps.zos3lite_gateway_domain.outcome }}
149170
- **Kubernetes**: ${{ steps.k8s.outcome }}
150171
- **Vmq QSFS**: skipped https://github.com/threefoldtech/tfgrid-sdk-ts/issues/3611
151172
- **Kubernetes QSFS**: skipped https://github.com/threefoldtech/tfgrid-sdk-ts/issues/3611

packages/grid_client/scripts/multiple_vms.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FilterOptions, GridClient, MachinesModel } from "../src";
1+
import { FilterOptions, generateString, GridClient, MachinesModel } from "../src";
22
import { config, getClient } from "./client_loader";
33
import { log, pingNodes } from "./utils";
44

@@ -30,7 +30,13 @@ async function getNodeId(client: GridClient, options: FilterOptions) {
3030
}
3131

3232
async function main() {
33-
const name = "monVMS2";
33+
const name = "vm" + generateString(6);
34+
const networkName = "nw" + generateString(6);
35+
const machine1Name = "machine" + generateString(6);
36+
const machine2Name = "machine" + generateString(6);
37+
const disk1Name = "disk" + generateString(6);
38+
const disk2Name = "disk" + generateString(6);
39+
3440
const grid3 = await getClient(`vm/${name}`);
3541

3642
const vmQueryOptions: FilterOptions = {
@@ -46,16 +52,16 @@ async function main() {
4652
const vms: MachinesModel = {
4753
name,
4854
network: {
49-
name: "monNetwork",
55+
name: networkName,
5056
ip_range: "10.238.0.0/16",
5157
},
5258
machines: [
5359
{
54-
name: "testvm1",
60+
name: machine1Name,
5561
node_id: nodeId!,
5662
disks: [
5763
{
58-
name: "newDisk1",
64+
name: disk1Name,
5965
size: 5,
6066
mountpoint: "/newDisk1",
6167
},
@@ -74,11 +80,11 @@ async function main() {
7480
},
7581
},
7682
{
77-
name: "testvm2",
83+
name: machine2Name,
7884
node_id: nodeId!,
7985
disks: [
8086
{
81-
name: "newDisk2",
87+
name: disk2Name,
8288
size: 5,
8389
mountpoint: "/newDisk2",
8490
},
@@ -107,7 +113,7 @@ async function main() {
107113
//Get the deployment
108114
await getDeployment(grid3, name);
109115

110-
// //Uncomment the line below to cancel the deployment
116+
// Uncomment the line below to cancel the deployment
111117
// await cancel(grid3, name);
112118

113119
await grid3.disconnect();
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import {
2+
Features,
3+
FilterOptions,
4+
generateRandomHexSeed,
5+
generateString,
6+
GridClient,
7+
MachinesDeleteModel,
8+
MachinesModel,
9+
} from "../src";
10+
import { config, getClient } from "./client_loader";
11+
import { log, pingNodes } from "./utils";
12+
13+
async function deploy(client: GridClient, vms: MachinesModel) {
14+
const res = await client.machines.deploy(vms);
15+
log("================= Deploying VM =================");
16+
log(res);
17+
log("================= Deploying VM =================");
18+
}
19+
20+
async function getDeployment(client: GridClient, name: string) {
21+
const res = await client.machines.getObj(name);
22+
log("================= Getting deployment information =================");
23+
log(res);
24+
log("================= Getting deployment information =================");
25+
}
26+
27+
async function cancel(client: GridClient, name: string) {
28+
const res = await client.machines.delete({ name });
29+
log("================= Canceling the deployment =================");
30+
log(res);
31+
log("================= Canceling the deployment =================");
32+
}
33+
34+
async function getNodeId(client: GridClient, options: FilterOptions) {
35+
const nodes = await client.capacity.filterNodes(options);
36+
const nodeId = await pingNodes(client, nodes);
37+
return nodeId;
38+
}
39+
40+
async function main() {
41+
const name = "vm" + generateString(6);
42+
const networkName = "nw" + generateString(6);
43+
const machine1Name = "machine" + generateString(6);
44+
const machine2Name = "machine" + generateString(6);
45+
const disk1Name = "disk" + generateString(6);
46+
const disk2Name = "disk" + generateString(6);
47+
48+
const grid3 = await getClient(`vm/${name}`);
49+
50+
const vmQueryOptions: FilterOptions = {
51+
cru: 1,
52+
mru: 1, // GB
53+
sru: 14,
54+
availableFor: grid3.twinId,
55+
features: [Features.zmachinelight, Features.networklight, Features.mycelium],
56+
nodeExclude: [259],
57+
farmName: "LiriaFarm",
58+
};
59+
60+
const nodeId = await getNodeId(grid3, vmQueryOptions);
61+
62+
const vms: MachinesModel = {
63+
name,
64+
network: {
65+
name: networkName,
66+
ip_range: "10.238.0.0/16",
67+
},
68+
machines: [
69+
{
70+
name: machine1Name,
71+
node_id: nodeId!,
72+
disks: [
73+
{
74+
name: disk1Name,
75+
size: 5,
76+
mountpoint: "/newDisk1",
77+
},
78+
],
79+
public_ip: false,
80+
public_ip6: false,
81+
planetary: false,
82+
mycelium: true,
83+
cpu: 1,
84+
memory: 1024,
85+
rootfs_size: 0,
86+
flist: "https://hub.grid.tf/tf-official-apps/base:latest.flist",
87+
entrypoint: "/sbin/zinit init",
88+
env: {
89+
SSH_KEY: config.ssh_key,
90+
},
91+
},
92+
{
93+
name: machine2Name,
94+
node_id: nodeId!,
95+
disks: [
96+
{
97+
name: disk2Name,
98+
size: 5,
99+
mountpoint: "/newDisk2",
100+
},
101+
],
102+
public_ip: false,
103+
public_ip6: false,
104+
planetary: false,
105+
mycelium: true,
106+
cpu: 1,
107+
memory: 1024,
108+
rootfs_size: 0,
109+
flist: "https://hub.grid.tf/tf-official-apps/base:latest.flist",
110+
entrypoint: "/sbin/zinit init",
111+
env: {
112+
SSH_KEY: config.ssh_key,
113+
},
114+
},
115+
],
116+
metadata: "",
117+
description: "test deploying VMs via ts grid3 client",
118+
};
119+
120+
//Deploy VMs
121+
await deploy(grid3, vms);
122+
123+
//Get the deployment
124+
await getDeployment(grid3, name);
125+
126+
// Uncomment the line below to cancel the deployment
127+
// await cancel(grid3, name);
128+
129+
await grid3.disconnect();
130+
}
131+
132+
main();

packages/grid_client/scripts/single_vm.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GridClient, MachinesModel } from "../src";
1+
import { generateString, GridClient, MachinesModel } from "../src";
22
import { type ZmachineData } from "../src/helpers/types";
33
import { config, getClient } from "./client_loader";
44
import { log } from "./utils";
@@ -26,22 +26,26 @@ async function cancel(client: GridClient, name: string) {
2626
}
2727

2828
async function main() {
29-
const name = "newVMS";
29+
const name = "vm" + generateString(6);
30+
const networkName = "nw" + generateString(6);
31+
const machineName = "machine" + generateString(6);
32+
const diskName = "disk" + generateString(6);
33+
3034
const grid3 = await getClient(`vm/${name}`);
3135

3236
const vms: MachinesModel = {
3337
name,
3438
network: {
35-
name: "wedtest",
39+
name: networkName,
3640
ip_range: "10.249.0.0/16",
3741
},
3842
machines: [
3943
{
40-
name: "testvm",
44+
name: machineName,
4145
node_id: 11,
4246
disks: [
4347
{
44-
name: "wedDisk",
48+
name: diskName,
4549
size: 8,
4650
mountpoint: "/testdisk",
4751
},

packages/grid_client/scripts/single_vm_zos4.ts renamed to packages/grid_client/scripts/single_vm_zos3_lite.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { Features, FilterOptions, generateRandomHexSeed, GridClient, MachinesDeleteModel, MachinesModel } from "../src";
1+
import {
2+
Features,
3+
FilterOptions,
4+
generateRandomHexSeed,
5+
generateString,
6+
GridClient,
7+
MachinesDeleteModel,
8+
MachinesModel,
9+
} from "../src";
210
import { config, getClient } from "./client_loader";
311
import { log, pingNodes } from "./utils";
412

@@ -24,7 +32,8 @@ async function cancel(client, vms) {
2432
}
2533

2634
async function main() {
27-
const name = "vm";
35+
const name = "vm" + generateString(6);
36+
const networkName = "nw" + generateString(6);
2837
const grid3 = await getClient(`vm/${name}`);
2938
const instanceCapacity = { cru: 2, mru: 4, sru: 100 }; // Update the instance capacity values according to your requirements.
3039

@@ -36,14 +45,15 @@ async function main() {
3645
availableFor: grid3.twinId,
3746
features: [Features.zmachinelight, Features.networklight, Features.mycelium],
3847
nodeExclude: [259],
48+
farmName: "LiriaFarm",
3949
};
4050
const nodes = await grid3.capacity.filterNodes(vmQueryOptions);
4151
const vmNode = await pingNodes(grid3, nodes);
4252

4353
const vms: MachinesModel = {
4454
name,
4555
network: {
46-
name: "vmNode",
56+
name: networkName,
4757
ip_range: "10.249.0.0/16",
4858
myceliumSeeds: [
4959
{
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { Features, FilterOptions, GatewayNameModel, generateString } from "../src";
2+
import { getClient } from "./client_loader";
3+
import { log } from "./utils";
4+
5+
async function deploy(client, gw) {
6+
const res = await client.gateway.deploy_name(gw);
7+
log("================= Deploying name gateway =================");
8+
log(res);
9+
log("================= Deploying name gateway =================");
10+
}
11+
12+
async function getDeployment(client, gw) {
13+
const res = await client.gateway.getObj(gw);
14+
log("================= Getting deployment information =================");
15+
log(res);
16+
log("================= Getting deployment information =================");
17+
}
18+
19+
async function cancel(client, gw) {
20+
const res = await client.gateway.delete_name(gw);
21+
log("================= Canceling the deployment =================");
22+
log(res);
23+
log("================= Canceling the deployment =================");
24+
}
25+
26+
// read more about the gateway types in this doc: https://github.com/threefoldtech/zos/tree/main/docs/internals/gateway
27+
async function main() {
28+
const grid3 = await getClient();
29+
const gatewayName = "gw" + generateString(6);
30+
31+
const gatewayQueryOptions: FilterOptions = {
32+
gateway: true,
33+
features: [Features.mycelium, Features.zmachinelight, Features.networklight],
34+
farmName: "LiriaFarm",
35+
};
36+
37+
const gw: GatewayNameModel = {
38+
name: gatewayName,
39+
node_id: +(await grid3.capacity.filterNodes(gatewayQueryOptions))[0].nodeId,
40+
tls_passthrough: false,
41+
// the backends have to be in this format `http://ip:port` or `https://ip:port`, and the `ip` pingable from the node so using the ygg ip or public ip if available.
42+
backends: ["http://185.206.122.35:8000"],
43+
};
44+
45+
//Deploy gateway
46+
await deploy(grid3, gw);
47+
48+
//Get the deployment
49+
await getDeployment(grid3, gw.name);
50+
51+
//Uncomment the line below to cancel the deployment
52+
// await cancel(grid3, { name: gw.name });
53+
54+
grid3.disconnect();
55+
}
56+
57+
main();

0 commit comments

Comments
 (0)