Esempio n. 1
0
    def test_win_uninstall_standalone(self):
        query = BuildQuery()
        builds, changes = query.get_all_builds()
        os_version = self.input.test_params['win']

        task = 'uninstall'
        ex_type = 'exe'
        bat_file = 'uninstall.bat'
        version_file = 'VERSION.txt'
        if self.input.test_params["ostype"] == '64':
            Arch = 'x86_64'
            os_type = '64'
        elif self.input.test_params["ostype"] == '32':
            Arch = 'x86'
            os_type = '32'
        else:
            ok = False
            self.log.error("Unknown os version.")

        product = self.input.test_params["product"]
        if product == 'cse':
            name = 'couchbase-server-enterprise'
        elif product == 'csse':
            name = 'couchbase-single-server-enterprise'
        elif product == 'csc':
            name = 'couchbase-server-community'
        elif product == 'cssc':
            name = 'couchbase-single-server-community'
        else:
            self.log.error("Unknon product type.")

        # no need later
        cb_server_alias = ['cse','csc']
        cb_single_alias = ['csse','cssc']
        if product in cb_server_alias:
            server_path = "/cygdrive/c/Program Files/Couchbase/Server/"
        elif product in cb_single_alias:
            server_path = "/cygdrive/c/Program Files (x86)/Couchbase/Server/"

        for serverInfo in self.servers:
                remote_client = RemoteMachineShellConnection(serverInfo)
                info = RemoteMachineShellConnection(serverInfo).extract_remote_info()

                exist = remote_client.file_exists(server_path, version_file)
                if exist:
                    build_name, version = remote_client.find_build_version(server_path, version_file)
                    self.log.info('build needed to do auto uninstall {0}'.format(build_name))
                    # find installed build in tmp directory
                    build_name = build_name.rstrip() + ".exe"
                    self.log.info('Check if {0} is in tmp directory'.format(build_name))
                    exist = remote_client.file_exists("/cygdrive/c/tmp/", build_name)
                    if not exist:
                        build = query.find_build(builds, name, ex_type, Arch, version)
                        downloaded = remote_client.download_binary_in_win(build.url,product,version)
                        if downloaded:
                            self.log.info('Successful download {0}_{1}.exe'.format(product, version))
                        else:
                            self.log.error('Download {0}_{1}.exe failed'.format(product, version))
                    # modify uninstall bat file to change build name.
                    remote_client.modify_bat_file('/cygdrive/c/automation', bat_file,
                                                      product, os_type, os_version, version, task)
                    self.log.info('sleep for 5 seconds before running task schedule uninstall')
                    time.sleep(5)
                    # run task schedule to uninstall Couchbase Server
                    self.log.info('Start to uninstall couchbase {0}_{1}'.format(product, version))
                    output, error = remote_client.execute_command("cmd /c schtasks /run /tn removeme")
                    remote_client.log_command_output(output, error)
                    remote_client.wait_till_file_deleted(server_path, version_file, timeout_in_seconds=600)
                    self.log.info('sleep 15 seconds before running the next job ...')
                    time.sleep(15)
                else:
                    self.log.info('Couchbase server may not install on this server')
Esempio n. 2
0
    def test_win_install(self):
        query = BuildQuery()
        builds, changes = query.get_all_builds()
        version = self.input.test_params['version']
        os_version = self.input.test_params['win']

        task = 'install'
        ok = True
        ex_type = 'exe'
        bat_file = 'install.bat'
        version_file = 'VERSION.txt'
        if self.input.test_params["ostype"] == '64':
            Arch = 'x86_64'
            os_type = '64'
        elif self.input.test_params["ostype"] == '32':
            Arch = 'x86'
            os_type = '32'
        else:
            ok = False
            self.log.error("Unknown os version.")

        product = self.input.test_params["product"]
        if product == 'cse':
            name = 'couchbase-server-enterprise'
        elif product == 'csse':
            name = 'couchbase-single-server-enterprise'
        elif product == 'csc':
            name = 'couchbase-server-community'
        elif product == 'cssc':
            name = 'couchbase-single-server-community'
        else:
            ok = False
            self.log.error("Unknon product type.")

        cb_server_alias = ['cse','csc']
        cb_single_alias = ['csse','cssc']
        if product in cb_server_alias:
            server_path = "/cygdrive/c/Program Files/Couchbase/Server/"
        elif product in cb_single_alias:
            server_path = "/cygdrive/c/Program Files (x86)/Couchbase/Server/"

        if ok:
            for serverInfo in self.servers:
                remote_client = RemoteMachineShellConnection(serverInfo)
                info = RemoteMachineShellConnection(serverInfo).extract_remote_info()
                build = query.find_build(builds, name, ex_type, Arch, version)
                #self.log.info("what is this {0}".format(build.url))
                # check if previous couchbase server installed
                exist = remote_client.file_exists("/cygdrive/c/Program Files/Couchbase/Server/", version_file)
                if exist:
                    # call uninstall function to install couchbase server
                    self.log.info("Start uninstall cb server on this server")
                    self.test_win_uninstall(remote_client, product, os_type, os_version, version, server_path)
                else:
                    self.log.info('I am free. You can install couchbase server now')
                # directory path in remote server used to create or delete directory
                dir_paths = ['/cygdrive/c/automation','/cygdrive/c/tmp']
                remote_client.create_multiple_dir(dir_paths)
                # copy files from local server to remote server
                remote_client.copy_files_local_to_remote('resources/windows/automation', '/cygdrive/c/automation')
                downloaded = remote_client.download_binary_in_win(build.url,product,version)
                if downloaded:
                    self.log.info('Successful download {0}_{1}.exe'.format(product, version))
                else:
                    self.log.error('Download {0}_{1}.exe failed'.format(product, version))
                remote_client.modify_bat_file('/cygdrive/c/automation', bat_file,
                                               product, os_type, os_version, version, task)
                self.log.info('sleep for 5 seconds before running task schedule install me')
                time.sleep(5)
                # run task schedule to install Couchbase Server
                output, error = remote_client.execute_command("cmd /c schtasks /run /tn installme")
                remote_client.log_command_output(output, error)
                remote_client.wait_till_file_added(server_path, version_file, timeout_in_seconds=600)
                self.log.info('sleep 15 seconds before running the next job ...')
                time.sleep(15)
        else:
            self.log.error("Can not install Couchbase Server.")