예제 #1
0
def generate_zone_deleted():
    zone_name = datagen.random_zone_name()
    serial = 123456
    tools.add_new_zone_to_bind(zone_name, serial=serial)

    # ask digaas to poll for the zone until it disappears from the nameserver
    resp = client.post_poll_request(
        query_name = zone_name,
        nameserver = NAMESERVER,
        serial = 0,
        condition = client.ZONE_REMOVED,
        start_time = time.time(),
        timeout = 15,
        frequency = 1)
    assert resp.status_code == 202
    id = resp.json()['id']

    # wait a bit before removing the zone
    duration = random.randint(2, 10)
    time.sleep(duration)
    rndc.delzone(zone_name)

    # wait for digaas to finish polling
    client.wait_for_completed_poll_request(id)
    resp = client.get_poll_request(id)

    print "Generated datapoint for zone removed {0}: {1} {2}".format(
        resp.json()['query_name'],
        resp.json()['start_time'],
        resp.json()['duration']
    )
예제 #2
0
    def test_poll_for_zone_removed(self):
        # add a random zone to the nameserver with a known serial
        zone_name = datagen.random_zone_name()
        tools.add_new_zone_to_bind(zone_name)

        # ask digaas to poll until the zone is removed from the nameserver
        resp = self.client.post_poll_request(
            query_name=zone_name,
            nameserver=NAMESERVER,
            serial=0,
            condition=self.client.ZONE_REMOVED,
            start_time=time.time(),
            timeout=15,
            frequency=1,
        )
        self.assertEqual(resp.status_code, 202)
        id = resp.json()["id"]

        # wait two seconds before we remove the zone
        min_duration = 2
        time.sleep(min_duration)
        tools.touch_zone(zone_name)

        rndc.delzone(zone_name)

        # wait for the digaas to timeout on the poll request
        self.client.wait_for_completed_poll_request(id)
        resp = self.client.get_poll_request(id)

        # check the entire response body
        self.assertGreater(resp.json()["duration"], min_duration)
        self.assertEqual(resp.json()["query_name"], zone_name)
        self.assertEqual(resp.json()["nameserver"], NAMESERVER)
        self.assertEqual(resp.json()["frequency"], 1)
        self.assertEqual(resp.json()["timeout"], 15)
        self.assertEqual(resp.json()["condition"], self.client.ZONE_REMOVED)
        self.assertEqual(resp.json()["rdatatype"], None)
        self.assertEqual(resp.json()["status"], "COMPLETED")
        self.assertEqual(resp.json()["id"], id)