Skip to content

Commit

Permalink
[#602] Normalize flower tests methods (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
ablatov authored and Dmitrii Suslov committed Nov 16, 2018
1 parent 5f42b7d commit 70c883b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
7 changes: 5 additions & 2 deletions legion_test/legion_test/robot/flower.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,8 @@ def wait_for_worker_is_ready(self, expected_count=1):
:return: None
"""
expected_count = int(expected_count)
wait_until(lambda: self.get_number_of_workers_from_flower() >= expected_count,
iteration_duration=5, iterations=35)
worker_ready = wait_until(lambda: self.get_number_of_workers_from_flower() == expected_count,
iteration_duration=10, iterations=30)
if not worker_ready:
raise Exception("Expected ready workers count '{}' does not match actual '{}'"
.format(expected_count, self.get_number_of_workers_from_flower()))
7 changes: 5 additions & 2 deletions legion_test/legion_test/robot/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,11 @@ def wait_deployment_replicas_count(self, deployment_name, namespace='default', e
:return: None
"""
expected_replicas_num = int(expected_replicas_num)
wait_until(lambda: self.get_deployment_replicas(deployment_name, namespace) >= expected_replicas_num,
iteration_duration=5, iterations=35)
result = wait_until(lambda: self.get_deployment_replicas(deployment_name, namespace) == expected_replicas_num,
iteration_duration=5, iterations=35)
if not result:
raise Exception("Expected ready replicas count '{}' does not match actual '{}'"
.format(expected_replicas_num, self.get_deployment_replicas(deployment_name, namespace)))

def set_deployment_replicas(self, replicas, deployment_name, namespace='default'):
"""
Expand Down
8 changes: 7 additions & 1 deletion tests/robot/resources/keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,10 @@ Run airflow task and validate stderr
:FOR ${task} IN @{tasks}
\ ${date_time} = Get Current Date result_format='%Y-%m-%d %H:%M:%S'
\ ${status} = Trigger Airflow task ${dag} ${task} ${date_time}
\ Should Be Equal ${status} ${None}
\ Should Be Equal ${status} ${None}

Set replicas num
[Arguments] ${replicas_num}
:FOR ${enclave} IN @{ENCLAVES}
\ Set deployment replicas ${replicas_num} airflow-${enclave}-worker ${enclave}
Wait deployment replicas count airflow-${enclave}-worker namespace=${enclave} expected_replicas_num=${replicas_num}
52 changes: 26 additions & 26 deletions tests/robot/tests/1_common/1.3_check_flower.robot
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@ Check if flower available
Check if flower scale up works properly
[Documentation] Scale up Flower deployment and check if number of celery workers increases
[Tags] airflow flower scale apps
[Setup] Set replicas num ${1}
:FOR ${enclave} IN @{ENCLAVES}
\ Connect to enclave Flower ${enclave}
${workers_number} = Get number of workers from Flower
Log Current workers number is ${workers_number}
${active_workers_exists}= Wait for worker is ready expected_count=1
${workers_number} = Get number of workers from Flower
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
Should be equal as integers ${workers_number} ${replicas_number} Workers number doesn't equal to Replicas number
${new_replicas_number} = Sum up ${replicas_number} ${1}
Set deployment replicas ${new_replicas_number} airflow-${enclave}-worker ${enclave}
${replicas}= Wait deployment replicas count airflow-${enclave}-worker namespace=${enclave} expected_replicas_num=${new_replicas_number}
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
${active_workers_exists}= Wait for worker is ready expected_count=${new_replicas_number}
${workers_number} = Get number of workers from Flower
Should be equal as integers ${new_replicas_number} ${replicas_number} Actual Replicas values doens't equal to set Replicas number
Should be equal as integers ${new_replicas_number} ${workers_number} Workers number hasn't been increased to new Replicas number
Wait for worker is ready expected_count=${1}
${workers_number} = Get number of workers from Flower
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
Should be equal as integers ${workers_number} ${replicas_number} Workers number doesn't equal to Replicas number
${new_replicas_number} = Sum up ${replicas_number} ${1}
Set deployment replicas ${new_replicas_number} airflow-${enclave}-worker ${enclave}
Wait deployment replicas count airflow-${enclave}-worker namespace=${enclave} expected_replicas_num=${new_replicas_number}
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
Wait for worker is ready expected_count=${new_replicas_number}
${workers_number} = Get number of workers from Flower
Should be equal as integers ${new_replicas_number} ${replicas_number} Actual Replicas values doens't equal to set Replicas number
Should be equal as integers ${new_replicas_number} ${workers_number} Workers number hasn't been increased to new Replicas number

Check if flower scale down works properly
[Documentation] Scale down Flower deployment and check if number of celery workers decreases
[Tags] airflow flower scale apps
[Setup] Set replicas num ${2}
:FOR ${enclave} IN @{ENCLAVES}
\ Connect to enclave Flower ${enclave}
${workers_number} = Get number of workers from Flower
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
Should be equal as integers ${workers_number} ${replicas_number} Workers number doesn't equal to Replicas number
Should be True ${replicas_number}>1 Replicas number should be greater than 1 to start this test
${new_replicas_number} = Subtract ${replicas_number} ${1}
Set deployment replicas ${new_replicas_number} airflow-${enclave}-worker ${enclave}
${replicas}= Wait deployment replicas count airflow-${enclave}-worker namespace=${enclave} expected_replicas_num=${new_replicas_number}
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
${active_workers_exists}= Wait for worker is ready expected_count=${new_replicas_number}
${workers_number} = Get number of workers from Flower
Should be equal as integers ${new_replicas_number} ${workers_number} Actual Replicas values doens't equal to set Replicas number
Should be equal as integers ${new_replicas_number} ${replicas_number} Workers number hasn't been decreased to new Replicas number
Wait for worker is ready expected_count=${2}
${workers_number} = Get number of workers from Flower
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
Should be equal as integers ${workers_number} ${replicas_number} Workers number doesn't equal to Replicas number
${new_replicas_number} = Subtract ${replicas_number} ${1}
Set deployment replicas ${new_replicas_number} airflow-${enclave}-worker ${enclave}
Wait deployment replicas count airflow-${enclave}-worker namespace=${enclave} expected_replicas_num=${new_replicas_number}
${replicas_number} = Get deployment replicas airflow-${enclave}-worker ${enclave}
Wait for worker is ready expected_count=${new_replicas_number}
${workers_number} = Get number of workers from Flower
Should be equal as integers ${new_replicas_number} ${workers_number} Actual Replicas values doens't equal to set Replicas number
Should be equal as integers ${new_replicas_number} ${replicas_number} Workers number hasn't been decreased to new Replicas number

0 comments on commit 70c883b

Please sign in to comment.