1import unittest
2import TestInput
3import logger
4from membase.api.rest_client import RestConnection
5
6log = logger.Logger.get_logger()
7
8class VerifyVersionTest(unittest.TestCase):
9    servers = None
10    log = None
11    input = TestInput.TestInput
12
13    def setUp(self):
14        self.log = logger.Logger.get_logger()
15        self.input = TestInput.TestInputSingleton.input
16        self.assertTrue(self.input, msg="input parameters missing...")
17        self.servers = self.input.servers
18
19
20    # read each server's version number and compare it to self.version
21    def test_verify_version(self):
22        expected_version = self.input.test_params['version']
23        for serverInfo in self.servers:
24            rest = RestConnection(serverInfo)
25            rest.log_client_error('test_verify_version test-method running')
26            version = rest.get_pools()
27            self.log.info('expected version on node {0} is {1}'.format(serverInfo.ip, expected_version))
28            self.log.info('actual version on node {0} is {1}'.format(serverInfo.ip, version.implementationVersion))
29            if version.implementationVersion.startswith(expected_version.lower()):
30                self.log.info("CORRECT VERSION INSTALLED")
31            else:
32                self.assertEqual(first=expected_version,
33                             second=version.implementationVersion,
34                             msg='INCORRECT VERSION INSTALLED for server @ %s' % serverInfo.ip)
35