Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Service test #1

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8475cc0
Started implementing assertion utils
ANKerD Apr 18, 2019
2ef0bd4
Add assertttrue function to TestSuite
ANKerD Apr 23, 2019
3a211b5
Implemented framework for TestAssertions
ANKerD Apr 23, 2019
9d708ac
attemp to implement hook at test method
ANKerD Apr 23, 2019
6a22e91
Removed __getattribute__ from TestSuite
ANKerD Apr 23, 2019
31901f4
Refactor some tests on AS service test
ANKerD Apr 24, 2019
e0a3e4c
Removed unecessary checks
ANKerD Apr 24, 2019
36aae4b
Started installing dependencies.properties
ANKerD Apr 24, 2019
3bb8720
Fixed installation of dependencies.properties
ANKerD Apr 25, 2019
22e8aba
Implemented tests for version and public key
ANKerD Apr 25, 2019
b3a5de8
More tests for MS
ANKerD Apr 29, 2019
7e8225b
Started implementing RAS system tests
ANKerD May 7, 2019
614f158
Implemented support to dependent services
ANKerD May 8, 2019
ccbcd31
Remvoed unnecessary __init__ overrides
ANKerD May 8, 2019
ba76848
Implemented logging of REST requests and fixed logic problems with as…
ANKerD May 9, 2019
07a996f
Implemented ceration of Compute and Network
ANKerD May 13, 2019
b9a53df
Implement create volume and attachemnt tests
ANKerD May 13, 2019
d98db59
Decouple order creation from assertions
ANKerD May 13, 2019
593e2c1
Wrap ras API calls in model class
ANKerD May 14, 2019
bfbd0f5
Implemented some fail to deleting network and computes
ANKerD May 15, 2019
fc278b2
Removed verbose log of REST requests
ANKerD May 15, 2019
5e9a360
Implemented more tests for computes and networks
ANKerD May 15, 2019
4f92895
Implemented Emulated Cloud Public Ip Plugin
ANKerD May 23, 2019
e5a96b8
Add test_resources to repo
ANKerD May 24, 2019
76d972d
WIP: refactor security rules tests
ANKerD Jun 5, 2019
59f1629
Change command to run services
ANKerD Jun 5, 2019
bfd34f7
WIP: test remote clouds
ANKerD Jun 7, 2019
405e23b
Chaanges old test_factory class to FogbowHttpUtil for clearer naming
ANKerD Jun 11, 2019
7e3f1fb
RAS tests check all clouds and members
ANKerD Jun 11, 2019
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/*.pyc
**/__pycache__/
**/private/*
**/.vscode
21 changes: 10 additions & 11 deletions scripts/install-dependencies.properities.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,38 @@
import re

if len(sys.argv) == 1:
print "No argument passed"
print("No argument passed")
exit(1)

if len(sys.argv) > 2:
print "More than 1 parameter given"
print("More than 1 parameter given")
exit(-1)

with open(sys.argv[1]) as f:
content = f.readlines()


for line in content:

os.chdir('..')

dependency, target = line.split('=')

if target == None or target == '':
target = 'develop'

project = dependency.split("/")[-1].split(".")[0]
repository = re.search("[^/]+(?=\.git)", dependency).group(0)
print "> git clone \"%s\" into \"%s\"" % (dependency, project)

print("> git clone \"%s\" into \"%s\"" % (dependency, project))
os.system("git clone " + dependency)

print "> cd %s" % repository
print("> cd %s" % repository)
os.chdir(repository)

print "> git checkout " + target
print("> git checkout " + target)
os.system("git checkout " + target)

print os.getcwd()
print(os.getcwd())

print "> mvn install"
print("> mvn install")
os.system("mvn install")
2 changes: 0 additions & 2 deletions service_test/.gitignore

This file was deleted.

3 changes: 1 addition & 2 deletions service_test/authentication_service/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

from .service_tests import *
from .general_configuration_test import *

modules = [service_tests, general_configuration_test]
modules = [service_tests]

__all__ = [prop for module in modules for prop in module.__all__]
13 changes: 0 additions & 13 deletions service_test/authentication_service/general_configuration_test.py

This file was deleted.

69 changes: 30 additions & 39 deletions service_test/authentication_service/service_tests.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,46 @@
# -*- coding: utf-8 -*-
import requests
import shutil

from common import TestSuite, TestEngine
from common import FogbowHttpUtil, VersionandPublicKeyCheck

__all__ = ['AuthTest']

class AuthTest(TestSuite):
class AuthTest(VersionandPublicKeyCheck):

def __init__(self, service, configuration, resources):
TestSuite.__init__(self, service)
self.conf = configuration
self.pid = None
self.resources = resources
self.port = self.conf['application']['port']
self.origin = 'http://localhost:' + str(self.port)
super().__init__(service, configuration, resources)

def setup(self):
repo_url = self.conf['application']['repo_url']
branch = self.conf['application']['branch_under_test']

self.clonerepo(repo_url, branch)

command = self.conf['commands']['run_application']
port = self.port

pid = self.run_in_background(command, port)
def run(self):
try:
super().run()
self.createtoken()
self.failcreatetoken()
except Exception as e:
self.fail()
print("Interruped execution due to runtime error")
raise e
finally:
self.logresults()

print("pid for proccess is %s" % pid)
self.setpid(pid)
def createtoken(self):
self.__createtokentest__('Creating token', \
self.resources['auth_credentials'], \
self.assertlt)

def teardown(self):
print('tasketeeee')
# self.kill_background_process(self.pid)
# shutil.rmtree(self.workdir)
def failcreatetoken(self):
self.__createtokentest__('Fail attemp to create token', \
self.resources['invalid_auth_credentials'], \
self.assertge)

def run(self):
self.createtoken()
def __createtokentest__ (self, message, credentials, assertion):
self.starttest(message)

def createtoken(self):
self.logTest('Creating token')
test = TestEngine(self.origin)
credentials = self.resources['auth_credentials']
test = FogbowHttpUtil(self.origin)
res = test.create('token', body=credentials)
token = res['token']
print('Token %s was obtained' % token)
# body = json.lao

def setpid(self, pid):
self.pid = pid

assertion(res.status_code, 400)

self.endtest()

@classmethod
def required_resources(self):
return ['auth_credentials']
return ['auth_credentials', 'invalid_auth_credentials']
9 changes: 6 additions & 3 deletions service_test/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
from .constants import *
from .http_methods import *
from .instance_states import *
from .test_factory import *
from .test_suite import *
from .service_test_instance import *
from .fogbow_http_util import *
from .utils import *
from .check_version import *
from .check_version_and_public_key import *

modules = [constants, http_methods, instance_states, test_suite, test_factory, utils]
modules = [constants, http_methods, instance_states, service_test_instance,
fogbow_http_util, utils, check_version, check_version_and_public_key]

__all__ = [prop for module in modules for prop in module.__all__]
23 changes: 23 additions & 0 deletions service_test/common/assertion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

""" Util class for ServiceTestInstance """
class Assertion(object):

def __init__(self, suite, compare):
self.compare = compare
self.suite = suite

def __call__(self, obtained, expected=None):
if expected != None:
assertpassed = self.compare(obtained,expected)
else:
assertpassed = self.compare(obtained)

if assertpassed:
self.suite.__assertion_ok__()
else:
print("Assertion failed: given: {}, expected {}".format(obtained, expected))
self.suite.__assertion_fail__()

return assertpassed

22 changes: 22 additions & 0 deletions service_test/common/check_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-

from .service_test_instance import ServiceTestInstance
from .fogbow_http_util import FogbowHttpUtil

__all__ = ['VersionCheck']

class VersionCheck(ServiceTestInstance):

def run(self):
self.version()

def version(self):
self.starttest('Requesting version')

test = FogbowHttpUtil(self.origin)
res = test.get('version').json()
version = res['version']

self.assertgt(len(version), 0)

self.endtest()
24 changes: 24 additions & 0 deletions service_test/common/check_version_and_public_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-

from .service_test_instance import ServiceTestInstance
from .fogbow_http_util import FogbowHttpUtil
from .check_version import VersionCheck

__all__ = ['VersionandPublicKeyCheck']

class VersionandPublicKeyCheck(VersionCheck):

def run(self):
super().run()
self.publickey()

def publickey(self):
self.starttest('Requesting public key')

test = FogbowHttpUtil(self.origin)
res = test.get('public-key').json()
publickey = res['publicKey']

self.assertgt(len(publickey), 0)

self.endtest()
2 changes: 2 additions & 0 deletions service_test/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
class CommonConstants:
resource_path = 'src/main/resources/'
private = 'private'
dependencies_properties = 'dependencies.properties'
install_dependencies_script = 'python2 {}/../../scripts/install-dependencies.properities.py'
Loading