Skip to content

Commit

Permalink
Merge branch 'development' into development_2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Jun 20, 2024
2 parents d0d4e08 + cf5fbac commit 73281ec
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 34 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/grid_client_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
- uses: actions/checkout@v4
if: ${{ env.NETWORK == 'qa' }}
with:
ref: refs/tags/v2.4.3
ref: refs/tags/v2.5.0-rc2
- uses: actions/checkout@v4
if: ${{ env.NETWORK == 'test' }}
with:
ref: refs/tags/v2.4.3
ref: refs/tags/v2.5.0-rc2
- uses: actions/checkout@v4
if: ${{ env.NETWORK == 'main' }}
with:
Expand Down Expand Up @@ -134,7 +134,12 @@ jobs:
steps.deleteall.outcome != 'success'
run: exit 1

- name: Get the day of the week
id: dayofweek
run: echo "DAY_OF_WEEK=$(date +%u)" >> $GITHUB_ENV

- name: Create GitHub Issue on Failure
if: needs.teststatus.result == 'failure' && env.DAY_OF_WEEK != '5' && env.DAY_OF_WEEK != '6'
uses: dacbd/create-issue-action@main
with:
token: ${{ github.token }}
Expand All @@ -151,7 +156,6 @@ jobs:
- Commit: ${{ github.sha }}
- Network: `${{ env.NETWORK }}`


Dynamic Single Vm: ${{ steps.dynamicsinglevm.outcome }}
Multiple Vm: ${{ steps.multiplevm.outcome }}
Kubernetes: ${{ steps.kubernetes.outcome }}
Expand All @@ -160,5 +164,4 @@ jobs:
Kvstore: ${{ steps.kvstore.outcome }}
Zdb: ${{ steps.zdb.outcome }}
Delete all contracts: ${{ steps.deleteall.outcome }}
labels: type_bug , grid_client

labels: type_bug, grid_client
66 changes: 66 additions & 0 deletions packages/grid_client/tests/modules/compute_capacity.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ComputeCapacity } from "../../src";

let computeCapacity: ComputeCapacity;

beforeEach(() => {
computeCapacity = new ComputeCapacity();
});
describe("Compute Capacity module", () => {
test("Compute Capacity instance is of type ComputeCapacity.", () => {
expect(computeCapacity).toBeInstanceOf(ComputeCapacity);
});

test("Min values for cpu & memory.", () => {
const cpu = 0;
const mem = 255 * 1024 ** 2;

computeCapacity.cpu = cpu;
computeCapacity.memory = mem;

const result = () => computeCapacity.challenge();

expect(result).toThrow();
});

test("Max values for cpu & memory.", () => {
const cpu = 33;
const mem = 255 * 1024 ** 4;

computeCapacity.cpu = cpu;
computeCapacity.memory = mem;

const result = () => computeCapacity.challenge();

expect(result).toThrow();
});

test("cpu & memory doesn't accept decimal values.", () => {
const cpu = 1.5;
const mem = 1.2;

computeCapacity.cpu = cpu;
computeCapacity.memory = mem;

const result = () => computeCapacity.challenge();

expect(result).toThrow();
});

test("cpu & memory empty values.", () => {
const result = () => computeCapacity.challenge();

expect(result).toThrow();
});

test("An error should be thrown if cpu & memory negative values.", () => {
const negative_cpu = -1;
const negative_mem = -1;

computeCapacity.cpu = negative_cpu;
computeCapacity.memory = negative_mem;

const result = () => computeCapacity.challenge();

expect(result).toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
above.</v-alert
>

<v-card-actions>
<v-card-actions class="justify-end mb-1 mr-2">
<v-btn color="anchor" class="mr-2 px-3" @click="contractStateDialog = false"> Close </v-btn>
<v-tooltip
:text="
Expand Down Expand Up @@ -247,7 +247,7 @@
<v-chip class="ma-1" label v-for="c in selectedContracts" :key="c.contract_id">
{{ c.contract_id }}
</v-chip>
<v-card-actions>
<v-card-actions class="justify-end mb-1 mr-2">
<v-btn color="anchor" @click="unlockDialog = false"> Cancel </v-btn>
<v-tooltip
:text="
Expand Down Expand Up @@ -343,11 +343,11 @@ const getAmountLocked = computed(() => {
const isNodeInRentContracts = computed(() => {
if (props.contractsType == ContractType.Node && selectedItem.value) {
const nodeIds = props.contracts.value
.map(contract => contract.details.nodeId)
.filter(nodeId => nodeId !== undefined) as number[];
const nodeIds = new Set(
props.contracts.value.map(contract => contract.details.nodeId).filter(nodeId => nodeId !== undefined) as number[],
);
if (contractLocked.value && contractLocked.value.amountLocked === 0) {
return nodeIds.includes(selectedItem.value.nodeId);
return nodeIds.has(selectedItem.value.details.nodeId);
}
}
return false;
Expand Down
43 changes: 23 additions & 20 deletions packages/playground/src/components/node_selector/TfDomainName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<template #append-item v-if="pagination.page !== -1">
<VContainer>
<VBtn
@click="reloadDomains()"
@click="loadDomains"
block
color="secondary"
variant="tonal"
Expand All @@ -65,7 +65,7 @@
</template>
<template v-slot:append>
<v-slide-x-reverse-transition mode="out-in">
<v-icon icon="mdi-reload" @click="reloadDomains()"></v-icon>
<v-icon icon="mdi-reload" @click="reloadDomains"></v-icon>
</v-slide-x-reverse-transition>
</template>
</VAutocomplete>
Expand Down Expand Up @@ -149,26 +149,28 @@ export default {
farmId: enableCustomDomain.value ? props.farm?.farmId : undefined,
availableFor: gridStore.client.twinId,
}));
const selectedDomain = ref<NodeInfo | null>(null);
const loadDomains = () => domainsTask.value.run(gridStore, filters.value);
const reloadDomains = async (_filters: FilterOptions = filters.value) => {
if (selectedDomain.value) {
selectedDomain.value = null;
bindModelValue();
bindStatus();
}
await pageCountTask.value.run(gridStore, _filters);
pagination.value.reset(pageCountTask.value.data as number);
await nextTick();
loadedDomains.value = [];
return loadDomains();
};
const reloadDomains = () => domainsTask.value.run(gridStore, filters.value);
useWatchDeep(
filters,
async filters => {
await pageCountTask.value.run(gridStore, filters);
pagination.value.reset(pageCountTask.value.data as number);
await nextTick();
loadedDomains.value = [];
return reloadDomains();
},
{
immediate: true,
deep: true,
ignoreFields: ["page"],
},
);
useWatchDeep(filters, reloadDomains, {
immediate: true,
deep: true,
ignoreFields: ["page"],
});
const customDomain = ref("");
const selectedDomain = ref<NodeInfo | null>(null);
const domainNameValid = ref<boolean | null>(null);
watch(domainNameValid, valid => {
Expand Down Expand Up @@ -235,6 +237,7 @@ export default {
domainsTask,
loadedDomains,
selectedDomain,
loadDomains,
reloadDomains,
disableSelectedDomain,
Expand Down
3 changes: 1 addition & 2 deletions packages/playground/src/views/nodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,7 @@ export default {
sortBy: SortBy.Status,
sortOrder: SortOrder.Asc,
numGpu: +filters.value.numGpu || undefined,
rentable: filters.value.rentable && profileManager.profile ? filters.value.rentable : undefined,
availableFor: filters.value.rentable && profileManager.profile ? profileManager.profile.twinId : undefined,
rentable: filters.value.rentable ? filters.value.rentable : undefined,
hasIPv6: filters.value.ipv6 ? filters.value.ipv6 : undefined,
rentedBy: filters.value.mine && profileManager.profile ? profileManager.profile.twinId : undefined,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/src/weblets/tf_contracts_list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
color="warning"
@click="unlockAllContracts"
:loading="unlockContractLoading"
class="ml-2"
>
Unlock contracts
</v-btn>
Expand Down Expand Up @@ -336,7 +337,7 @@ async function loadContracts(type?: ContractType, options?: { sort: { key: strin
loadContractsByType(ContractType.Rent, rentContracts, options),
]);
}
await getContractsLockDetails();
contracts.value = [...nodeContracts.value, ...nameContracts.value, ...rentContracts.value];
// Update the total cost of the contracts.
Expand Down

0 comments on commit 73281ec

Please sign in to comment.