From e1bd9670013f1c14cb40847117bf046ca81a26ab Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Wed, 25 Apr 2018 14:54:07 -0400 Subject: [PATCH] Fix race in test_hold_expiration_no_default The test_hold_expiration_no_default test was misconfigured to use the nodepool config for the max ready age tests, which was causing a race in the test where the node could be removed (b/c it exceeded the max ready age) before it could set a hold. This fixes it to use a new config, and lowers the TTL on the held node to quicken the test. Change-Id: Iaeb16e7a11f8b5c7bb2b363b7939fee7933393c4 --- .../node_max_hold_age_no_default.yaml | 48 +++++++++++++++++++ nodepool/tests/test_launcher.py | 4 +- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 nodepool/tests/fixtures/node_max_hold_age_no_default.yaml diff --git a/nodepool/tests/fixtures/node_max_hold_age_no_default.yaml b/nodepool/tests/fixtures/node_max_hold_age_no_default.yaml new file mode 100644 index 000000000..b42ae1612 --- /dev/null +++ b/nodepool/tests/fixtures/node_max_hold_age_no_default.yaml @@ -0,0 +1,48 @@ +elements-dir: . +images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' + +zookeeper-servers: + - host: {zookeeper_host} + port: {zookeeper_port} + chroot: {zookeeper_chroot} + +labels: + - name: fake-label + min-ready: 1 + +providers: + - name: fake-provider + cloud: fake + driver: fake + region-name: fake-region + rate: 0.0001 + diskimages: + - name: fake-image + meta: + key: value + key2: value + pools: + - name: main + max-servers: 96 + availability-zones: + - az1 + networks: + - net-name + labels: + - name: fake-label + diskimage: fake-image + min-ram: 8192 + flavor-name: 'Fake' + +diskimages: + - name: fake-image + elements: + - fedora + - vm + release: 21 + env-vars: + TMPDIR: /opt/dib_tmp + DIB_IMAGE_CACHE: /opt/dib_cache + DIB_CLOUD_IMAGES: http://download.fedoraproject.org/pub/fedora/linux/releases/test/21-Beta/Cloud/Images/x86_64/ + BASE_IMAGE_FILE: Fedora-Cloud-Base-20141029-21_Beta.x86_64.qcow2 diff --git a/nodepool/tests/test_launcher.py b/nodepool/tests/test_launcher.py index 199c7afe5..672b94756 100644 --- a/nodepool/tests/test_launcher.py +++ b/nodepool/tests/test_launcher.py @@ -735,7 +735,7 @@ class TestLauncher(tests.DBTestCase): def test_hold_expiration_no_default(self): """Test a held node is deleted when past its operator-specified TTL, no max-hold-age set""" - configfile = self.setup_config('node_max_ready_age.yaml') + configfile = self.setup_config('node_max_hold_age_no_default.yaml') pool = self.useNodepool(configfile, watermark_sleep=1) self.useBuilder(configfile) pool.start() @@ -748,7 +748,7 @@ class TestLauncher(tests.DBTestCase): # hold the node node.state = zk.HOLD node.comment = 'testing' - node.hold_expiration = 5 + node.hold_expiration = 1 self.zk.lockNode(node, blocking=False) self.zk.storeNode(node) self.zk.unlockNode(node)