def setUp(self):

        # create repertories and configure harnesss
        self.tmpdir  = mkdtemp(prefix='harnais_')
        os.environ["TMPDIR"] = self.tmpdir
        self.staging_post = join(self.tmpdir, "staging_post")
        os.mkdir(self.staging_post)
        # prepare settings
        SettingsManager.load_settings()
        SettingsManager.update(dict(harnaisLogdir=self.tmpdir,
                                harnaisDir=self.tmpdir,
                                harnaisAckDir=self.tmpdir
                                ), testing=True)

        os.environ[ENV.settings] = join(self.tmpdir, "settings_testing.yaml")


        with open(os.environ[ENV.settings], "w") as file_:
            yaml.dump(dict(SettingsManager._parameters), file_)
        SettingsManager.reset()
        # configure SOAP server
        self.hostname = hostname = socket.gethostname()
        self.port = port = os.environ.get(ENV.port) or PORT
        self.soap_url = os.environ[ENV.soap_url]= ('http://{hostname}:{port}/harnais-diss-v2/'
                                    'webservice/Dissemination?wsdl'.format(hostname=hostname,
                                    port=port))
        SoapServer.create_server()
        # connect to soap WSDL
        self.client = Client(self.soap_url)
        self.factory = self.client.type_factory('http://dissemination.harness.openwis.org/')
 def tearDown(self):
     cleared = Tools.move_dir_to_trash_can(self.tmpdir)
     if not cleared:
         rmtree(self.tmpdir)
     os.environ.pop(ENV.settings)
     os.environ.pop("TMPDIR")
     tempfile.tempdir = None
     Database.reset()
     SettingsManager.reset()
    def setUp(self):

        # configuring settings and repertories
        DebugSettingsManager.debug = "False"
        DebugSettingsManager.test_sftp = "True"
        self.tmpdir  = mkdtemp(prefix='harnais_')
        harnais_dir = join(self.tmpdir, "harnais")
        os.mkdir(harnais_dir)
        os.environ["TMPDIR"] = self.tmpdir
        self.staging_post = join(self.tmpdir, "staging_post")
        os.mkdir(self.staging_post)
        self.difmet_deposit = join(self.tmpdir, "difmet_deposit")
        os.mkdir(self.difmet_deposit)
        self.ack_dir = join(self.tmpdir, "ack_dir")
        os.mkdir(self.ack_dir)

        # create files on staging post
        for i in range(2):
            with open(join(self.staging_post,"A_SNFR30LFPW270700_C_LFPW_20180927070000_%i.txt" % i),"w") as file_out:
                file_out.write("Dummy staging post test file")


        # configure soap server
        self.hostname = hostname = socket.gethostname()
        self.port = port = os.environ.get(ENV.port) or PORT
        self.soap_url = os.environ[ENV.soap_url]= ('http://{hostname}:{port}/harnais-diss-v2/'
                         'webservice/Dissemination?wsdl'.format(hostname=hostname,
                         port=port))


        SettingsManager.load_settings()
        SettingsManager.update(dict(harnaisLogdir=harnais_dir,
                                    harnaisDir=harnais_dir,
                                    harnaisAckDir=self.ack_dir,
                                    openwisStagingPath=gettempdir(),
                                    openwisHost="localhost",
                                    openwisSftpUser="******",
                                    openwisSftpPassword="******",
                                    openwisSftpPort = 3373,
                                    processFileIdle = 10,
                                    dissHost="0.0." + "0.0",
                                    dissFtpUser="******",
                                    dissFtpPasswd="12345",
                                    dissFtpDir=self.difmet_deposit,
                                    dissFtpMode=None,
                                    dissFtpPort=2121,
                                    sendFTPlimitConn=5),
                               testing=True)

        os.environ[ENV.settings] = join(self.tmpdir, "settings_testing.yaml")

        with open(os.environ[ENV.settings], "w") as file_:
            yaml.dump(dict(SettingsManager._parameters), file_)
        SettingsManager.reset()
 def tearDown(self):
     #clearing repertories
     cleared = Tools.move_dir_to_trash_can(self.tmpdir)
     if not cleared:
         rmtree(self.tmpdir)
     SFTPserver.stop_server()
     os.environ.pop(ENV.settings)
     os.environ.pop("TMPDIR")
     tempfile.tempdir = None
     Database.reset()
     SettingsManager.reset()
     DebugSettingsManager.reset()
Exemple #5
0
 def tearDown(self):
     #stopping FTP server
     FTPserver.stop_server()
     #clearing repertories
     cleared = Tools.move_dir_to_trash_can(self.tmpdir)
     if not cleared:
         rmtree(self.tmpdir)
     # cleaning up environment
     os.environ.pop(ENV.settings)
     os.environ.pop("TMPDIR")
     tempfile.tempdir = None
     SettingsManager.reset()
     HarnessTree.reset()
Exemple #6
0
 def tearDown(self):
     cleared = Tools.move_dir_to_trash_can(self.tmpdir)
     if not cleared:
         rmtree(self.tmpdir)
     # Stop sftp server
     SFTPserver.stop_server()
     os.environ.pop(ENV.settings)
     os.environ.pop("TMPDIR")
     tempfile.tempdir = None
     Database.reset()
     SettingsManager.reset()
     HarnessTree.reset()
     DebugSettingsManager.reset()
Exemple #7
0
    def test_download_large_file(self):
        """
        We check that download a big file on staging post is not an issue
        """
        self.assertTrue(file_manager.manager.TEST_SFTP)

        SettingsManager.reset()
        SettingsManager.load_settings()
        SettingsManager.update(dict(harnaisLogdir=self.tmpdir,
                                    harnaisDir=self.tmpdir,
                                    harnaisAckDir=self.tmpdir,
                                    openwisStagingPath=gettempdir(),
                                    openwisHost="localhost",
                                    openwisSftpUser="******",
                                    openwisSftpPassword="******",
                                    openwisSftpPort=3373,
                                    bandwidth=5),
                               testing=True)

        with open(os.environ[ENV.settings], "w") as file_:
            yaml.dump(SettingsManager._parameters, file_)

        files_list = []
        for i in range(1):
            filename = "A_largefile_C_LFPW_20180927070000_%i.txt" % i
            files_list.append(filename)
            with open(join(self.staging_post, filename), "wb") as file_out:
                size = 200 * (1 << 20)
                file_out.seek(size - 1)
                file_out.write(b"\0")

        FileManager.process_instruction_file(self.json_file)

        dir_b = HarnessTree.get("temp_dissRequest_B")

        for filename in files_list:
            self.assertTrue(os.path.isfile(join(dir_b, filename)))