コード例 #1
0
ファイル: gttestcase.py プロジェクト: hammer/genetorrent
    def data_download_test_xml(self, xml_file_name, uuids,
        client_options='', server_options='', check_sha1=True):
        server = None
        # delete the bams so we can download them
        for uuid in uuids:
            if os.path.isfile(self.client_bam(uuid)):
                os.remove(self.client_bam(uuid))

        if TestConfig.MOCKHUB:
            # prepare server
            server = GeneTorrentInstance(
                '-s server%sroot -q server%sworkdir -c %s ' \
                '--security-api %s %s' \
                % (
                    os.path.sep,
                    os.path.sep,
                    self.cred_filename,
                    TestConfig.SECURITY_API,
                    server_options,
                ), instance_type=InstanceType.GT_SERVER)

            # add new download GTO to server work queue
            # add gt_download_mode flag to server gto
            for uuid in uuids:
                gtodict = read_gto(self.client_gto(uuid))
                gtodict['gt_download_mode'] = 'true'
                expiry = time.time() + (1 * 3600 * 24) # expire in 1 day
                set_key(gtodict, 'expires on', int(expiry))
                emit_gto(gtodict, self.server_gto(uuid), True)
        else:
            self.upload_sleep(3)

        # prepare download client
        client = GeneTorrentInstance('-d %s ' \
            '-p client2 -c %s %s' \
            % (
                xml_file_name,
                self.cred_filename,
                client_options,
            ), instance_type=InstanceType.GT_DOWNLOAD)

        # wait for download client to exit
        client_sout, client_serr = client.communicate()

        if server:
            self.terminate_server(server)

        # check download client return code
        self.assertEqual(client.returncode, 0)

        self.assertTrue('Downloaded' in client_serr)
        self.assertTrue('state changed to: finished' in client_sout)

        # check file hashes on both sides of transfer
        for uuid in uuids:
            if check_sha1 and TestConfig.MOCKHUB:
                self.assertTrue(self.compare_hashes(
                    self.client_bam2(uuid), self.server_bam(uuid)))

        return client.returncode
コード例 #2
0
    def test_server_peer_verify(self):
        '''Test server client curl SSL peer verification behavior.'''
        uuid = uuid4()
        self.generate_bam_data(uuid, 1024)
        self.create_gto_only(uuid)

        # now, test server without --ssl-no-verify-ca

        server = GeneTorrentInstance( \
            '-s %s -q %s -c %s --security-api ' \
            '%s ' \
            '--foreground -l stdout:full -R .' \
            %  ('server' + os.path.sep + 'root',
                'server' + os.path.sep + 'workdir',
                self.cred_filename,
                TestConfig.SECURITY_API
                ), ssl_no_verify_ca=False, instance_type=InstanceType.GT_SERVER,
                add_defaults=False)

        # copy gto to server
        client_gto = self.client_gto(uuid)
        server_gto = self.server_gto(uuid)

        gtodict = read_gto(client_gto)
        gtodict['gto_download_mode'] = 'true'
        emit_gto(gtodict, server_gto, True)

        time.sleep(10)

        # kill server
        server.kill()

        # check for SSL signing error
        server.stdout_buffer.seek(0)
        server_sout = server.stdout_buffer.read()
        print server_sout
        self.assertTrue('while attempting a CSR signing transaction' in \
            server_sout)
コード例 #3
0
ファイル: gttestcase.py プロジェクト: hammer/genetorrent
    def data_download_test_uuid(self, uuid, client_options='', server_options='',
        check_sha1=True, assert_rc=0, assert_serr='', server_ct=1):
        # delete the bam so we can download it
        if os.path.isfile(self.client_bam(uuid)):
            os.remove(self.client_bam(uuid))

        servers = []

        if TestConfig.MOCKHUB:
            # prepare server(s)
            for i in range(0, server_ct):
                server = GeneTorrentInstance(
                    '-s server%sroot -q server%sworkdir -c %s ' \
                    '--security-api %s %s' \
                    % (
                        os.path.sep,
                        os.path.sep,
                        self.cred_filename,
                        TestConfig.SECURITY_API,
                        server_options,
                    ), instance_type=InstanceType.GT_SERVER,
                    client_num=i)

                servers.append(server)

            # add new download GTO to server work queue
            # add gt_download_mode flag to server gto
            gtodict = read_gto(self.client_gto(uuid))
            gtodict['gt_download_mode'] = 'true'
            expiry = time.time() + (1 * 3600 * 24) # expire in 1 day
            set_key(gtodict, 'expires on', int(expiry))
            emit_gto(gtodict, self.server_gto(uuid), True)
        else:
            self.upload_sleep(3)

        # prepare download client
        client = GeneTorrentInstance('-d %s/cghub/data/analysis/download/%s ' \
            '-p client2 %s %s' \
            % (
                TestConfig.HUB_SERVER,
                str(uuid),
                '-c ' + self.cred_filename if not '-c ' in client_options else '',
                client_options,
            ), instance_type=InstanceType.GT_DOWNLOAD)

        # wait for download client to exit
        client_sout, client_serr = client.communicate()

        if servers:
            for server in servers:
                self.terminate_server(server)

        # check download client return code
        self.assertEqual(client.returncode, assert_rc)

        # caller-passed client_serr contains assert
        if assert_serr:
            self.assertTrue(assert_serr in client_serr)

        # only continue checking if assert_rc == 0
        if assert_rc == 0:
            # check download client
            self.assertTrue('Downloaded' in client_serr)
            self.assertTrue('state changed to: finished' in client_sout)

            # check file hashes on both sides of transfer
            if servers and check_sha1:
                self.assertTrue(self.compare_hashes(
                    self.client_bam2(uuid), self.server_bam(uuid)))

        return client.returncode