Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make integration tests working with python3 #937

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cosmic-core/test/integration/tests/cosmic/SshClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
SFTPClient
)

from codes import (
from .codes import (
SUCCESS,
FAILED,
INVALID_INPUT
Expand Down
10 changes: 5 additions & 5 deletions cosmic-core/test/integration/tests/cosmic/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import base64
from abc import ABCMeta, abstractmethod

from common import *
from utils import *
from .common import *
from .utils import *


class BaseAbstract:
Expand Down Expand Up @@ -503,7 +503,7 @@ def create(cls, api_client, services=None, templateid=None, accountid=None, doma
# TODO: This is probably not correct, fix it
cmd['details[0]["memory"]'] = custommemory

if rootdisksize >= 0:
if rootdisksize and rootdisksize >= 0:
cmd['details[0]["rootdisksize"]'] = rootdisksize

if group:
Expand Down Expand Up @@ -655,7 +655,7 @@ def validateState(self, api_client, state, timeout=600, interval=5):

@staticmethod
def state_check_function(objects, state):
return str(objects[0].state).lower().decode("string_escape") == str(state).lower()
return str(objects[0].state).lower() == str(state).lower()

def resetSshKey(self, api_client, **kwargs):
"""Resets SSH key"""
Expand Down Expand Up @@ -3638,7 +3638,7 @@ def create(cls, api_client, services=None, vpcofferingid=None, zoneid=None, netw
if "cidr" in services:
cmd['cidr'] = services["cidr"]
if account:
if isinstance(account, basestring):
if isinstance(account, str):
cmd['account'] = account
else:
cmd['account'] = account.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import time

from cosmicTestClient import CosmicTestClient
from .cosmicTestClient import CosmicTestClient


class cosmicTestCase(unittest.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions cosmic-core/test/integration/tests/cosmic/cosmicTestClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import copy
from cs import CloudStack

from cosmicLog import CosmicLog
from dbConnection import DbConnection
from utils import *
from .cosmicLog import CosmicLog
from .dbConnection import DbConnection
from .utils import *


class Cosmic(CloudStack):
Expand Down
4 changes: 2 additions & 2 deletions cosmic-core/test/integration/tests/cosmic/dbConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def executeSqlFromFile(self, fileName=None):

if __name__ == "__main__":
db = DbConnection()
print db.execute("update vm_template set name='fjkd' where id=200")
print(db.execute("update vm_template set name='fjkd' where id=200"))
for i in range(10):
result = db.execute("select job_status, created, last_updated from async_job where id=%d" % i)
print result
print(result)
8 changes: 4 additions & 4 deletions cosmic-core/test/integration/tests/cosmic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import sys
import time
import traceback
import urlparse

from SshClient import SshClient
from codes import *
from urllib.parse import urlparse
from .SshClient import SshClient
from .codes import *


class AttrDict(dict):
Expand Down Expand Up @@ -129,7 +129,7 @@ def attr(*args, **kwargs):
def wrap_ob(ob):
for name in args:
setattr(ob, name, True)
for name, value in kwargs.iteritems():
for name, value in kwargs.items():
setattr(ob, name, value)
return ob

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def _test_password_server_logs(self, vm, router):
router_state = self.get_router_state(router)

if router.isredundantrouter and router_state != "MASTER":
print "Found router in non-MASTER state '" + router.redundantstate + "' so skipping test."
print("Found router in non-MASTER state '" + router.redundantstate + "' so skipping test.")
return True

# Get the related passwd server logs for our vm
Expand Down
2 changes: 1 addition & 1 deletion cosmic-core/test/integration/tests/test_password_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def _test_password_server_logs(self, vm, router):
router_state = self.get_router_state(router)

if router.isredundantrouter and router_state != "MASTER":
print "Found router in non-MASTER state '" + router.redundantstate + "' so skipping test."
print("Found router in non-MASTER state '" + router.redundantstate + "' so skipping test.")
return True

# Get the related passwd server logs for our vm
Expand Down
2 changes: 1 addition & 1 deletion cosmic-core/test/integration/tests/test_vm_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ def test_02_migrate_back(self):
def get_dest_hypervisor(self, hostid=None):
if hostid is None:
hostid = self.vm.hostid
return filter(lambda x: x.id != hostid, self.hosts)
return list(filter(lambda x: x.id != hostid, self.hosts))