Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Iperf test from Grid Proxy #2519

Merged
merged 1 commit into from
Apr 8, 2024
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
2 changes: 0 additions & 2 deletions packages/playground/src/clients/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import TFGridGqlClient from "@threefold/graphql_client";
import GridProxyClient from "@threefold/gridproxy_client";
import { QueryClient } from "@threefold/tfchain_client";

const network = process.env.NETWORK || window.env.NETWORK;

const gqlClient = new TFGridGqlClient(window.env.GRAPHQL_URL);
const gridProxyClient = new GridProxyClient(window.env.GRIDPROXY_URL);
const queryClient = new QueryClient(window.env.SUBSTRATE_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

<v-row class="bb-gray" v-for="item in items" :key="item.name">
<v-col v-if="$props.iperf" class="font-14 d-flex justify-space-between">
<p class="ml-20 font-14">{{ item.name }}/{{ item.type }}</p>
<p class="ml-20 font-14">{{ item.name }}</p>
<div>
<v-icon icon="mdi-arrow-up"></v-icon>
<span class="mx-3">{{ item.uploadSpeed }}</span>
<span class="mx-2">{{ item.uploadSpeed }}</span>
</div>
<div>
<v-icon icon="mdi-arrow-down"></v-icon>
<span class="mx-3">{{ item.downloadSpeed }}</span>
<span class="mx-2">{{ item.downloadSpeed }}</span>
</div>
</v-col>
<v-col v-if="!$props.iperf" class="d-flex justify-start align-center ml-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { onMounted, type PropType, ref } from "vue";

import type { NodeDetailsCard } from "@/types";

import { useGrid } from "../../stores";
import { gridProxyClient } from "../../clients";
import formatResourceSize from "../../utils/format_resource_size";
import CardDetails from "./card_details.vue";

Expand All @@ -30,7 +30,6 @@ export default {
},

setup(props) {
const gridStore = useGrid();
const loading = ref<boolean>(false);
const IperfDetails = ref<NodeDetailsCard[]>();
const errorMessage = ref("");
Expand All @@ -50,30 +49,20 @@ export default {
});

function format(speed: number) {
return formatResourceSize(speed) + "/s" || "-";
}

function isIPv4(ip: string) {
const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}$/;
return ipv4Regex.test(ip);
return formatResourceSize(speed, true).toLocaleLowerCase() + "ps" || "-";
}

const getNodeIPerfCard = async (): Promise<NodeDetailsCard[]> => {
const res = await gridStore.grid.zos.getNodeIPerfTest({ nodeId: props.node.nodeId });
// filter the returned result to show node other than the one being tested against
const array = res.result
.filter(
(node: any) => node.download_speed && node.upload_speed && !node.error && node.node_id !== props.node.nodeId,
)
.slice(0, 4)
.map(node => ({
name: node.test_type.toLocaleUpperCase(),
type: isIPv4(node.node_ip) ? "IPv4" : "IPv6",
downloadSpeed: format(node.download_speed),
uploadSpeed: format(node.upload_speed),
}));

IperfDetails.value = array;
const { speed } = await gridProxyClient.nodes.byId(props.node.nodeId);
const upload = format(speed.upload);
const download = format(speed.download);
IperfDetails.value = [
{
name: "Speed",
uploadSpeed: upload,
downloadSpeed: download,
},
];
return IperfDetails.value;
};

Expand Down
Loading