# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import time


def wait_for_condition(condition, interval=1, timeout=60):
    start_time = time.time()
    end_time = time.time() + timeout
    while time.time() < end_time:
        result = condition()
        if result:
            return result
        time.sleep(interval)
    raise Exception(("Timed out after %s seconds.  Started on %s and ended "
                     "on %s") % (timeout, start_time, end_time))

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import time


def wait_for_condition(condition, interval=2, timeout=60):
    start_time = time.time()
    end_time = time.time() + timeout
    while time.time() < end_time:
        result = condition()
        if result:
            return result
        time.sleep(interval)
    raise Exception(("Timed out after %s seconds.  Started on %s and ended "
                     "on %s") % (timeout, start_time, end_time))

Change the tempest test interval to 2s.
Change the tempest test interval to 2s.

Always seen tempest test fail with api timeout error. Refer to
http://logs.openstack.org/42/469342/2/check/
gate-zun-devstack-dsvm-docker-sql/02b4650/
logs/apache/zun_api.txt.gz#_2017-05-31_08_29_52_459
But run the tempest in local devstack, the logs show there are
lots of rabbitmq messages and seems the rabbitmq cannot handle
so much message. Checked the code there are lots of check status
called in tempest test.

So this patch propose to change the check status interval to 2s
to reduce the numbers of messages to avoid rabbitmq message stuck.

Change-Id: Ibb41ae552bcce0f685834e13a6c3a5836f657cab
