Merge "Python3 code compatibility: division, round"
This commit is contained in:
commit
ca50c2f7a5
@ -11,6 +11,9 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@ -159,7 +162,7 @@ def check_ceph_image_size(ip, expected_size, device='vdc'):
|
|||||||
ssh_manager.check_call(ip=ip, cmd="df -m")))
|
ssh_manager.check_call(ip=ip, cmd="df -m")))
|
||||||
raise Exception()
|
raise Exception()
|
||||||
logger.debug("Partitions: {part}".format(part=ret))
|
logger.debug("Partitions: {part}".format(part=ret))
|
||||||
assert_true(abs(float(ret[0].rstrip()) / float(expected_size) - 1) < 0.1,
|
assert_true(abs(float(ret[0].rstrip()) / expected_size - 1) < 0.1,
|
||||||
"size {0} is not equal"
|
"size {0} is not equal"
|
||||||
" to {1}".format(ret[0].rstrip(),
|
" to {1}".format(ret[0].rstrip(),
|
||||||
expected_size))
|
expected_size))
|
||||||
@ -169,7 +172,7 @@ def check_ceph_image_size(ip, expected_size, device='vdc'):
|
|||||||
def check_cinder_image_size(ip, expected_size, device='vdc3'):
|
def check_cinder_image_size(ip, expected_size, device='vdc3'):
|
||||||
ret = get_mongo_partitions(ip, device)[0].rstrip().rstrip('G')
|
ret = get_mongo_partitions(ip, device)[0].rstrip().rstrip('G')
|
||||||
cinder_size = float(ret) * 1024
|
cinder_size = float(ret) * 1024
|
||||||
assert_true(abs(cinder_size / float(expected_size) - 1) < 0.1,
|
assert_true(abs(cinder_size / expected_size - 1) < 0.1,
|
||||||
"size {0} is not equal"
|
"size {0} is not equal"
|
||||||
" to {1}".format(ret[0].rstrip(),
|
" to {1}".format(ret[0].rstrip(),
|
||||||
expected_size))
|
expected_size))
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
# pylint: disable=no-name-in-module
|
# pylint: disable=no-name-in-module
|
||||||
from distutils import version
|
from distutils import version
|
||||||
@ -594,17 +596,17 @@ def node_freemem(remote, unit='MB'):
|
|||||||
swap_free = run_on_remote(remote, cmd_swap_free)[0]
|
swap_free = run_on_remote(remote, cmd_swap_free)[0]
|
||||||
ret = {
|
ret = {
|
||||||
"mem": {
|
"mem": {
|
||||||
"total": int(mem_free.split()[1]) / denominator,
|
"total": int(mem_free.split()[1]) // denominator,
|
||||||
"used": int(mem_free.split()[2]) / denominator,
|
"used": int(mem_free.split()[2]) // denominator,
|
||||||
"free": int(mem_free.split()[3]) / denominator,
|
"free": int(mem_free.split()[3]) // denominator,
|
||||||
"shared": int(mem_free.split()[4]) / denominator,
|
"shared": int(mem_free.split()[4]) // denominator,
|
||||||
"buffers": int(mem_free.split()[5]) / denominator,
|
"buffers": int(mem_free.split()[5]) // denominator,
|
||||||
"cached": int(mem_free.split()[6]) / denominator
|
"cached": int(mem_free.split()[6]) // denominator
|
||||||
},
|
},
|
||||||
"swap": {
|
"swap": {
|
||||||
"total": int(swap_free.split()[1]) / denominator,
|
"total": int(swap_free.split()[1]) // denominator,
|
||||||
"used": int(swap_free.split()[2]) / denominator,
|
"used": int(swap_free.split()[2]) // denominator,
|
||||||
"free": int(swap_free.split()[3]) / denominator,
|
"free": int(swap_free.split()[3]) // denominator,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
@ -1696,7 +1698,7 @@ class FuelWebClient(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_range(ip_network, ip_range=0):
|
def get_range(ip_network, ip_range=0):
|
||||||
net = list(netaddr.IPNetwork(str(ip_network)))
|
net = list(netaddr.IPNetwork(str(ip_network)))
|
||||||
half = len(net) / 2
|
half = len(net) // 2
|
||||||
if ip_range == 0:
|
if ip_range == 0:
|
||||||
return [[str(net[2]), str(net[-2])]]
|
return [[str(net[2]), str(net[-2])]]
|
||||||
elif ip_range == 1:
|
elif ip_range == 1:
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
@ -163,7 +165,7 @@ def get_job_parameter(jenkins_build_data, parameter):
|
|||||||
def get_version_from_parameters(jenkins_build_data):
|
def get_version_from_parameters(jenkins_build_data):
|
||||||
custom_version = get_job_parameter(jenkins_build_data, 'CUSTOM_VERSION')
|
custom_version = get_job_parameter(jenkins_build_data, 'CUSTOM_VERSION')
|
||||||
if custom_version:
|
if custom_version:
|
||||||
swarm_timestamp = jenkins_build_data['timestamp'] / 1000 \
|
swarm_timestamp = jenkins_build_data['timestamp'] // 1000 \
|
||||||
if 'timestamp' in jenkins_build_data else None
|
if 'timestamp' in jenkins_build_data else None
|
||||||
return (TestRailSettings.milestone,
|
return (TestRailSettings.milestone,
|
||||||
time.strftime("%D %H:%M", time.localtime(swarm_timestamp)),
|
time.strftime("%D %H:%M", time.localtime(swarm_timestamp)),
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import time
|
import time
|
||||||
@ -179,7 +181,9 @@ class ContrailPlugin(TestBasic):
|
|||||||
nailgun_nodes = \
|
nailgun_nodes = \
|
||||||
self.fuel_web.client.list_cluster_nodes(self.cluster_id)
|
self.fuel_web.client.list_cluster_nodes(self.cluster_id)
|
||||||
base_os_disk = 40960
|
base_os_disk = 40960
|
||||||
|
# pylint: disable=round-builtin
|
||||||
base_os_disk_gb = ("{0}G".format(round(base_os_disk / 1024, 1)))
|
base_os_disk_gb = ("{0}G".format(round(base_os_disk / 1024, 1)))
|
||||||
|
# pylint: enable=round-builtin
|
||||||
logger.info('disk size is {0}'.format(base_os_disk_gb))
|
logger.info('disk size is {0}'.format(base_os_disk_gb))
|
||||||
disk_part = {
|
disk_part = {
|
||||||
"vda": {
|
"vda": {
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
@ -153,7 +155,7 @@ class TestLogrotateBase(TestBasic):
|
|||||||
prefix[s] = 1 << (i + 1) * 10
|
prefix[s] = 1 << (i + 1) * 10
|
||||||
for s in reversed(symbols):
|
for s in reversed(symbols):
|
||||||
if data >= prefix[s]:
|
if data >= prefix[s]:
|
||||||
value = float(data) / prefix[s]
|
value = data / prefix[s]
|
||||||
return format(value, '.1f'), s
|
return format(value, '.1f'), s
|
||||||
return data, 'B'
|
return data, 'B'
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from devops.helpers.helpers import wait
|
from devops.helpers.helpers import wait
|
||||||
@ -674,7 +676,7 @@ class NodeDiskSizes(TestBasic):
|
|||||||
for disk in node['meta']['disks']:
|
for disk in node['meta']['disks']:
|
||||||
assert_equal(disk['size'], disk_size, 'Disk size')
|
assert_equal(disk['size'], disk_size, 'Disk size')
|
||||||
|
|
||||||
hdd_size = "{} TB HDD".format(float(disk_size * 3 / (10 ** 9)) / 1000)
|
hdd_size = "{} TB HDD".format((disk_size * 3 / (10 ** 9)) / 1000)
|
||||||
notifications = self.fuel_web.client.get_notifications()
|
notifications = self.fuel_web.client.get_notifications()
|
||||||
for node in nailgun_nodes:
|
for node in nailgun_nodes:
|
||||||
# assert /api/notifications
|
# assert /api/notifications
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from devops.helpers.helpers import wait
|
from devops.helpers.helpers import wait
|
||||||
@ -603,7 +605,7 @@ class TestMultipleClusterNets(TestBasic):
|
|||||||
# floating range
|
# floating range
|
||||||
public2_cidr = self.env.d_env.get_network(name='public2').ip
|
public2_cidr = self.env.d_env.get_network(name='public2').ip
|
||||||
new_settings_float = {
|
new_settings_float = {
|
||||||
'floating_ranges': [[str(public2_cidr[public2_cidr.numhosts / 2]),
|
'floating_ranges': [[str(public2_cidr[public2_cidr.numhosts // 2]),
|
||||||
str(public2_cidr[-2])]]
|
str(public2_cidr[-2])]]
|
||||||
}
|
}
|
||||||
self.fuel_web.client.update_network(cluster_id, new_settings_float)
|
self.fuel_web.client.update_network(cluster_id, new_settings_float)
|
||||||
|
@ -528,7 +528,9 @@ class CeilometerHAOneControllerMongo(OSTFCeilometerHelper):
|
|||||||
logger.debug('disk size is {0}'.format(disk_mb))
|
logger.debug('disk size is {0}'.format(disk_mb))
|
||||||
mongo_disk_mb = 11116
|
mongo_disk_mb = 11116
|
||||||
os_disk_mb = disk_mb - mongo_disk_mb
|
os_disk_mb = disk_mb - mongo_disk_mb
|
||||||
|
# pylint: disable=round-builtin
|
||||||
mongo_disk_gb = ("{0}G".format(round(mongo_disk_mb / 1024, 1)))
|
mongo_disk_gb = ("{0}G".format(round(mongo_disk_mb / 1024, 1)))
|
||||||
|
# pylint: enable=round-builtin
|
||||||
disk_part = {
|
disk_part = {
|
||||||
"vda": {
|
"vda": {
|
||||||
"os": os_disk_mb,
|
"os": os_disk_mb,
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from proboscis import SkipTest
|
from proboscis import SkipTest
|
||||||
@ -90,8 +93,10 @@ class PrepareActions(object):
|
|||||||
def _finish_case(self):
|
def _finish_case(self):
|
||||||
"""Finish test case"""
|
"""Finish test case"""
|
||||||
case_time = time.time() - self._start_time
|
case_time = time.time() - self._start_time
|
||||||
minutes = int(round(case_time)) / 60
|
minutes = case_time // 60
|
||||||
|
# pylint: disable=round-builtin
|
||||||
seconds = int(round(case_time)) % 60
|
seconds = int(round(case_time)) % 60
|
||||||
|
# pylint: enable=round-builtin
|
||||||
name = getattr(self, "__doc__",
|
name = getattr(self, "__doc__",
|
||||||
self.__class__.__name__).splitlines()[0]
|
self.__class__.__name__).splitlines()[0]
|
||||||
finish_case = "[ FINISH {} CASE TOOK {} min {} sec ]".format(
|
finish_case = "[ FINISH {} CASE TOOK {} min {} sec ]".format(
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import types
|
import types
|
||||||
|
|
||||||
@ -34,8 +36,10 @@ def step_start_stop(func):
|
|||||||
logger.info("\n{header}\n".format(header=header))
|
logger.info("\n{header}\n".format(header=header))
|
||||||
result = func(*args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
spent_time = timer.spent_time
|
spent_time = timer.spent_time
|
||||||
minutes = int(round(spent_time)) / 60
|
minutes = spent_time // 60
|
||||||
|
# pylint: disable=round-builtin
|
||||||
seconds = int(round(spent_time)) % 60
|
seconds = int(round(spent_time)) % 60
|
||||||
|
# pylint: enable=round-builtin
|
||||||
finish_step = "[ FINISH {} STEP TOOK {} min {} sec ]".format(
|
finish_step = "[ FINISH {} STEP TOOK {} min {} sec ]".format(
|
||||||
step_name, minutes, seconds)
|
step_name, minutes, seconds)
|
||||||
footer = "<<< {:-^142} >>>".format(finish_step)
|
footer = "<<< {:-^142} >>>".format(finish_step)
|
||||||
|
Loading…
Reference in New Issue
Block a user