Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonpille committed Jul 7, 2023
1 parent c392f76 commit cf4453d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions farmerbot/manager/node.v
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ fn (mut n NodeManager) find_node(mut job jobs.ActionJob) ! {

mut has_gpus := job.args.get_u8_default('has_gpus', 0)!
gpu_vendors := job.args.get_list_default('gpu_vendors', []string{}) or {
return error("Invalid list gpu_vendors: ${err}")
return error('Invalid list gpu_vendors: ${err}')
}
gpu_devices := job.args.get_list_default('gpu_devices', []string{}) or {
return error("Invalid list gpu_devices: ${err}")
return error('Invalid list gpu_devices: ${err}')
}
certified := job.args.get_default_false('certified')
public_config := job.args.get_default_false('public_config')
Expand Down Expand Up @@ -179,7 +179,7 @@ fn (mut n NodeManager) find_node(mut job jobs.ActionJob) ! {
// claim the resources until next update of the data
// add a timeout (30 minutes)
node.timeout_claimed_resources = time.now().add(time.minute * 30)
if dedicated {
if dedicated || has_gpus > 0 {
// claim all capacity
node.claim_resources(node.resources.total)
} else {
Expand Down
1 change: 0 additions & 1 deletion farmerbot/manager/power.v
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ mut:
}

pub fn (mut p PowerManager) on_started() {
// power on all nodes on start of farmerbot
p.logger.info("${manager.power_manager_prefix} Startup proces: powering on all nodes that are down.")
p.poweron_all_nodes()
}
Expand Down
5 changes: 5 additions & 0 deletions tests/nodemanager_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ fn test_find_node_dedicated() {
}

// assert

ensure_no_error(&job)!
ensure_result_contains_u32(&job, "nodeid", 20)!
resources_node_20 := t.farmerbot.db.get_node(20)!.resources
assert resources_node_20.used == resources_node_20.total, "All resources should be claimed when asking for a dedicated node!"
}
)!
}
Expand Down Expand Up @@ -255,6 +258,8 @@ fn test_find_node_with_gpu() {
// assert
ensure_no_error(&job)!
ensure_result_contains_u32(&job, "nodeid", 8)!
resources_node_8 := t.farmerbot.db.get_node(8)!.resources
assert resources_node_8.used == resources_node_8.total, "All resources should be claimed when asking for a gpu as the whole node should be rented!"
}
)!
}
Expand Down

0 comments on commit cf4453d

Please sign in to comment.