Skip to content

Commit

Permalink
Add unit tests for Minion Manager RPC Server
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergiu Miclea committed Nov 9, 2023
1 parent 39b3696 commit 10477eb
Show file tree
Hide file tree
Showing 7 changed files with 946 additions and 0 deletions.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# perform health checks for powered on machines
# skip health checks for non-powered on machines
- config:
minion_pool:
id: minion_pool1
minimum_minions: 4
minion_retention_strategy: delete
minion_machines:
- id: minion1
allocation_status: AVAILABLE
power_status: POWERED_ON
- id: minion2
allocation_status: ERROR
power_status: POWERED_ERROR
- id: minion3
allocation_status: AVAILABLE
power_status: POWERED_ON
- id: minion4
allocation_status: ERROR_DEPLOYING
power_status: POWERED_ON
expect:
result:
flow_tasks:
- pool-minion_pool1-machine-minion1-healthcheck
- pool-minion_pool1-machine-minion3-healthcheck
- pool-minion_pool1-machine-minion4-healthcheck
# "include" are the db calls that must be present
# "exclude" are the db calls that must not be present
db_calls:
include:
- set_minion_machine_allocation_status:
id: minion1
allocation_status: HEALTHCHECKING
- set_minion_machine_allocation_status:
id: minion3
allocation_status: HEALTHCHECKING
- set_minion_machine_allocation_status:
id: minion4
allocation_status: HEALTHCHECKING
exclude:
- set_minion_machine_allocation_status:
id: minion2
allocation_status: HEALTHCHECKING

# power off machines that are not needed
- config:
minion_pool:
id: minion_pool1
# minimum_minions 1 means we have too many minions
minimum_minions: 1
minion_max_idle_time: 0
minion_retention_strategy: poweroff
minion_machines:
- id: minion1
allocation_status: AVAILABLE
power_status: POWERED_ON
- id: minion2
allocation_status: ERROR
power_status: POWERED_ERROR
- id: minion3
allocation_status: AVAILABLE
power_status: POWERED_ON
- id: minion4
allocation_status: ERROR_DEPLOYING
power_status: POWERED_ON
expect:
result:
flow_tasks:
- pool-minion_pool1-machine-minion1-power-off
- pool-minion_pool1-machine-minion3-healthcheck
- pool-minion_pool1-machine-minion4-healthcheck
db_calls:
include:
- set_minion_machine_allocation_status:
id: minion1
allocation_status: POWERING_OFF
- set_minion_machine_allocation_status:
id: minion3
allocation_status: HEALTHCHECKING
- set_minion_machine_allocation_status:
id: minion4
allocation_status: HEALTHCHECKING
exclude:
- set_minion_machine_allocation_status:
id: minion2
allocation_status: HEALTHCHECKING
- set_minion_machine_allocation_status:
id: minion2
allocation_status: POWERING_OFF

# delete machines that are not needed
- config:
minion_pool:
id: minion_pool1
# minimum_minions 1 means we have too many minions
minimum_minions: 1
minion_max_idle_time: 0
minion_retention_strategy: delete
minion_machines:
- id: minion1
allocation_status: AVAILABLE
power_status: POWERING_OFF
- id: minion2
allocation_status: ERROR
power_status: POWERED_ERROR
- id: minion3
allocation_status: AVAILABLE
power_status: POWERED_ON
- id: minion4
allocation_status: ERROR_DEPLOYING
power_status: POWERED_ON
expect:
result:
flow_tasks:
- pool-minion_pool1-machine-minion1-deallocation
- pool-minion_pool1-machine-minion3-healthcheck
- pool-minion_pool1-machine-minion4-healthcheck
db_calls:
include:
- set_minion_machine_allocation_status:
id: minion1
allocation_status: DEALLOCATING
- set_minion_machine_allocation_status:
id: minion3
allocation_status: HEALTHCHECKING
- set_minion_machine_allocation_status:
id: minion4
allocation_status: HEALTHCHECKING
exclude:
- set_minion_machine_allocation_status:
id: minion2
allocation_status: HEALTHCHECKING
- set_minion_machine_allocation_status:
id: minion2
allocation_status: DEALLOCATING

# invalid retention strategy
- config:
minion_pool:
id: minion_pool1
# minimum_minions 1 means we have too many minions
minimum_minions: 1
minion_max_idle_time: 0
minion_retention_strategy: invalid
minion_machines:
- id: minion1
allocation_status: AVAILABLE
power_status: POWERING_OFF
- id: minion2
allocation_status: ERROR
power_status: POWERED_ERROR
- id: minion3
allocation_status: AVAILABLE
power_status: POWERED_ON
- id: minion4
allocation_status: ERROR_DEPLOYING
power_status: POWERED_ON
expect:
exception: InvalidMinionPoolState
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
## EXCEPTIONS

# requires 2 machines, but only 1 is available
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 1
minion_machines:
- allocation_status: AVAILABLE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
expect:
exception: InvalidMinionPoolState

# requires 2 machines, but only 1 is available
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 2
minion_machines:
- allocation_status: IN_USE
- allocation_status: AVAILABLE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
expect:
exception: InvalidMinionPoolState

# maximum_minions is too low for 4 new machines
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 6
minion_machines:
- id: machine_1
allocation_status: IN_USE
- id: machine_2
allocation_status: IN_USE
- id: machine_3
allocation_status: IN_USE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
instance_3:
name: Instance 3
instance_4:
name: Instance 4
expect:
exception: InvalidMinionPoolState

## SUCCESS

# no new machines need to be allocated
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 4
minion_machines:
- id: machine_1
allocation_status: AVAILABLE
- id: machine_2
allocation_status: AVAILABLE
- id: machine_3
allocation_status: AVAILABLE
- id: machine_4
allocation_status: AVAILABLE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
instance_3:
name: Instance 3
instance_4:
name: Instance 4
expect:
result:
mappings:
instance_1: machine_1
instance_2: machine_2
instance_3: machine_3
instance_4: machine_4

# 2 new machines are allocated
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 5
minion_machines:
- id: machine_1
allocation_status: AVAILABLE
- id: machine_2
allocation_status: IN_USE
- id: machine_3
allocation_status: AVAILABLE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
instance_3:
name: Instance 3
instance_4:
name: Instance 4
expect:
result:
mappings:
instance_1: machine_1
instance_2: machine_3
instance_3: new_machine
instance_4: new_machine

# 3 new machines are allocated
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 6
minion_machines:
- id: machine_1
allocation_status: AVAILABLE
- id: machine_2
allocation_status: IN_USE
- id: machine_3
allocation_status: IN_USE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
instance_3:
name: Instance 3
instance_4:
name: Instance 4
expect:
result:
mappings:
instance_1: machine_1
instance_2: new_machine
instance_3: new_machine
instance_4: new_machine

# 4 new machines are allocated
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 7
minion_machines:
- id: machine_1
allocation_status: IN_USE
- id: machine_2
allocation_status: IN_USE
- id: machine_3
allocation_status: IN_USE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
instance_3:
name: Instance 3
instance_4:
name: Instance 4
expect:
result:
mappings:
instance_1: new_machine
instance_2: new_machine
instance_3: new_machine
instance_4: new_machine

# 1 allocated
- config:
minion_pool:
id: minion_pool_1
maximum_minions: 4
minion_machines:
- id: machine_1
allocation_status: AVAILABLE
action_instances:
instance_1:
name: Instance 1
instance_2:
name: Instance 2
instance_3:
name: Instance 3
instance_4:
name: Instance 4
expect:
result:
mappings:
instance_1: machine_1
instance_2: new_machine
instance_3: new_machine
instance_4: new_machine
Loading

0 comments on commit 10477eb

Please sign in to comment.