Skip to content

Commit

Permalink
add test for task.capacity_type = control
Browse files Browse the repository at this point in the history
Test that control type tasks have the right capacity consumed and
get assigned to the right instance group

Also fix lint in the tests
  • Loading branch information
kdelee committed Feb 4, 2022
1 parent 53a239a commit 9ec387d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 0 additions & 1 deletion awx/main/tests/factories/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json

from django.contrib.auth.models import User
from django.conf import settings

from awx.main.models import (
Organization,
Expand Down
24 changes: 24 additions & 0 deletions awx/main/tests/functional/task_management/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ def test_hybrid_capacity(self, job_template, hybrid_instance):
], enough_capacity
assert expected_task_impact == hybrid_instance.consumed_capacity

@pytest.mark.django_db
def test_project_update_capacity(self, project, hybrid_instance, instance_group_factory, controlplane_instance_group):
pu = project.create_unified_job()
instance_group_factory(name='second_ig', instances=[hybrid_instance])
expected_task_impact = pu.task_impact + settings.AWX_CONTROL_NODE_TASK_IMPACT
pu.signal_start()

tm = TaskManager()
self.run_tm(tm)

pu.refresh_from_db()
assert pu.status == 'waiting'
assert [pu.execution_node, pu.controller_node] == [
hybrid_instance.hostname,
hybrid_instance.hostname,
], pu
assert expected_task_impact == hybrid_instance.consumed_capacity
# The hybrid node is in both instance groups, but the project update should
# always get assigned to the controlplane
assert pu.instance_group.name == settings.DEFAULT_CONTROL_PLANE_QUEUE_NAME
pu.status = 'successful'
pu.save()
assert hybrid_instance.consumed_capacity == 0


@pytest.mark.django_db
def test_single_jt_multi_job_launch_blocks_last(controlplane_instance_group, job_template_factory, mocker):
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tests/functional/test_instances.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from unittest import mock

from awx.main.models import AdHocCommand, InventoryUpdate, JobTemplate, ProjectUpdate
from awx.main.models import AdHocCommand, InventoryUpdate, JobTemplate
from awx.main.models.activity_stream import ActivityStream
from awx.main.models.ha import Instance, InstanceGroup
from awx.main.tasks.system import apply_cluster_membership_policies
Expand Down

0 comments on commit 9ec387d

Please sign in to comment.