示例#1
0
    def test_ArchiveCmd_Err_4_1(self):
        """
        Synopsis:
        Correct HTTP response, but illegal NG/AMS XML status document.

        Description:
        The purpose of the test is to verify that the C-Client/API handles
        correctly the situation where an incorrectly formatted XML status
        response is contained in the response from the server and the
        proper error code generated by the C-API.

        Expected Result:
        The C-API detects the wrongly formatted NG/AMS XML status document,
        and produces the appropriate error code.

        Test Steps:
        - Start special instance of the server which generates an HTTP
          response with a corrupt XML NG/AMS status document.
        - Issue an Archive Request via the ngamsCClient.
        - Compare the output from ngamsCClient to check that the invalid
          response was correctly handled.

        Remarks:
        ...
        """

        # TODO: From V4.0, this test case produces the error:
        #
        #  Error Code:     -103
        #  Message:        Invalid reply from data server
        #
        # - and not:
        #
        # Error Code:     -4
        # Message:        Problem communicating with server
        # Status:         FAILURE
        #
        # - as for previous version.
        #
        # This should be investigated and resolved.

        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_IllegalResp")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        httpResp = "HTTP/1.0 200 OK\015\012" +\
                   "Server: NGAMS/v2.3/2004-07-12T11:39:39\015\012" +\
                   "Date: Thu, 7 Oct 2004 16:20:28 GMT\015\012" +\
                   "Expires: Thu, 7 Oct 2004 16:20:28 GMT\015\012" +\
                   "Content-Type: text/xml\015\012" +\
                   "Content-Length: 36\015\012" +\
                   "\015\012" +\
                   "COMPLETELY CORRUPT NG/AMS XML STATUS"
        saveInFile("tmp/ngamsServerTestIllegalResp_tmp", httpResp)
        out = _execCClient(unpackXmlStat=0,
                           pars=[["-port", "8888"], ["-cmd", "ARCHIVE"],
                                 ["-fileUri", "src/SmallFile.fits"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_ArchiveCmd_Err_4_1_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of corrupt server HTTP response in C-Client/API")
示例#2
0
    def test_ArchiveCmd_Err_1(self):
        """
        Synopsis:
        Issue ARCHIVE Command/request times out.

        Description:
        The purpose of the test is to check that a request that times out
        is handled properly by the C-Client/API and a proper error message
        is produced.

        Expected Result:
        After the given timeout, the C-Client/API should generate a timeout
        error message.

        Test Steps:
        - Start speciel instance of server where Archive Requests blocks.
        - Issue Archive Request (small file) specifying a timeout of 10s.
        - Capture the output from the ngamsCClient, filter this, and
          check that the proper error message has been generated.

        Remarks:
        ...
        """
        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_BlockCmds1")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        out = _execCClient(unpackXmlStat=0,
                           pars=[["-port", "8888"], ["-cmd", "ARCHIVE"],
                                 ["-fileUri", "src/SmallFile.fits"],
                                 ["-timeOut", "5"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_ArchiveCmd_Err_1_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of timeout of Archive Request in C-Client/API")
示例#3
0
    def test_ChangeLocLogLev_1(self):
        """
        Synopsis:
        Change the Local (Log File) Log Level Online.

        Description:
        The purpose of this Test Case is to test that the Local Log Level
        can be changed while the NG/AMS Server is Online.

        Expected Result:
        The Log Level should be increased and more logs produced in the Local
        Log File.

        Test Steps:
        - Start normal NG/AMS Server (Log Level=3).
        - Send a CONFIG Command to the server changing the Log Level to 4.
        - Check the response to the CONFIG Command is correct.

        Remarks:
        TODO: Check in Log File that low level logs are produced.
        """
        self.prepExtSrv()
        statObj = sendPclCmd().get_status(NGAMS_CONFIG_CMD,
                                          pars=[["log_local_log_level", "4"]])
        tmpStatFile = "tmp/ngamsConfigCmdTest_test_ChangeLocLogLev_1_1_tmp"
        refStatFile = "ref/ngamsConfigCmdTest_test_ChangeLocLogLev_1_1_ref"
        saveInFile(
            tmpStatFile,
            filterOutLines(statObj.dumpBuf(), ["Date", "Version", "HostId"]))
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect info in " +\
                          "CONFIG Command XML Status " +
                          "Document/log_local_log_level")
示例#4
0
    def test_ServerLoad_1(self):
        """
        Synopsis:
        Test that the NG/AMS Server is loading configuration from DB and
        initializing as expected.

        Description:
        Test that the NG/AMS Server can load the configuration properly from
        the DB and initialize accordingly.

        Expected Result:
        The server should load the DB parameters according the specified
        NGAS Configuration ID specified and should start up properly.

        Test Steps:
        - Load the configuration into the DB.
        - Start an NG/AMS Server specifying an XML document which only
          defines the DB connection + giving the reference to the DB Cfg. ID.
        - Verify that the NG/AMS Server starts up properly.

        Remarks:
        ...
        """
        cfgName = "test_ServerLoad_1"
        cfgObj, _ = self.loadCfg(cfgName)
        cfgFile = saveInFile(None, str(cfgObj.genXmlDoc()))
        self.prepExtSrv(cfgFile=cfgFile, dbCfgName=cfgName, clearDb=0)

        # Archive a file, should be OK.
        statObj = sendPclCmd().archive("src/SmallFile.fits")
        refStatFile = "ref/ngamsConfigHandlingTest_test_ServerLoad_1_1_ref"
        tmpStatFile = saveInFile(None, filterDbStatus1(statObj.dumpBuf()))
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect status " +\
                          "returned for Archive Push Request")
示例#5
0
    def test_StatusCmd_5(self):
        """
        Synopsis:
        Issue STATUS Command/disk_id.

        Description:
        Test that the C-Client/API can handle STATUS Command with -diskId.

        Expected Result:
        The STATUS Command requesting for info about a specified disk,
        should be properly transferred via the C-Client/API and executed
        on the server.

        Test Steps:
        - Start server.
        - Issue STATUS Command requesting for info about a certain disk.
        - Compare the returned XML disk info with a reference file.

        Remarks:
        ...
        """
        cfgObj, dbObj = self.prepExtSrv(port=8111)
        diskId = "tmp-ngamsTest-NGAS-FitsStorage1-Main-1"
        statObj = _execCClient(pars=[["-cmd", "STATUS"], ["-diskId", diskId],
                                     ["-port", "8111"]])[0]
        tmpStatFile = "tmp/ngamsCClientTest_test_StatusCmd_5_1_tmp"
        refStatFile = "ref/ngamsCClientTest_test_StatusCmd_5_1_ref"
        saveInFile(tmpStatFile,
                   filterOutLines(statObj.dumpBuf(), STD_DISK_STAT_FILT))
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect info in " +\
                          "STATUS Command XML Status Document/disk_id")
示例#6
0
    def test_StatusCmd_1(self):
        """
        Synopsis:
        Issue STATUS Command/basic (no parameters).

        Description:
        Issue a STATUS Command via the C-Client (on the shell).

        Expected Result:
        The STATUS Command should be accepted and executed by the C-Client
        and the server.

        Test Steps:
        - Start standard server.
        - Execute the ngamsCClient tool on the shell.
        - Capture the output from the ngamsCClient and compare this with the
          expected output.

        Remarks:
        ...

        """
        cfgObj, dbObj = self.prepExtSrv(port=8000)
        statObj = _execCClient(pars=[["-port", "8000"], ["-cmd", "STATUS"]])[0]
        refStatFile = "ref/ngamsCClientTest_test_StatusCmd_1_1_ref"
        refStatFile = saveInFile(
            None,
            loadFile(refStatFile) % (getHostName() + ":8000"))
        tmpStatFile = saveInFile(
            None, filterOutLines(statObj.dumpBuf(), ["Date", "Version"]))
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect info in " +\
                          "STATUS Command XML Status Document")
示例#7
0
    def test_RemDiskCmd_1(self):
        """
        Synopsis:
        Normal execution.

        Description:
        Test the normal execution of the REMDISK Command, where a disk,
        containing files with at least 3 independent copies is request
        REMDISK'ed.

        Expected Result:
        When executing the REMDISK Command on the cloned disk with execute=0,
        the server should accept the command and report this to the client.

        When re-issuing the REMDISK Command on the cloned disk with execute=1,
        the server should accept the command, execute the REMDISK procedure on
        the disk and report this to the client.

        Test Steps:
        - Start server.
        - Archive a file.
        - Clone the disk hosting the archived file.
        - Issue REMDISK Command to remove the cloned disk (execute=0).
        - Check response from the server.
        - Issue REMDISK Command to remove the cloned disk (execute=1).
        - Check response from the server.

        Remarks:
        TODO!: It is not checked that the contents on the disk and the info
               in the DB in ngas_files and ngas_disks is properly updated.
        """
        self.prepExtSrv(cfgProps=(('NgamsCfg.Server[1].RequestDbBackend', 'memory'),))
        client = sendPclCmd()

        # Archive a file + clone it to be able to execute the REMDISK Command.
        diskId = "tmp-ngamsTest-NGAS-FitsStorage1-Main-1"
        client.archive("src/SmallFile.fits")
        status = client.clone("", diskId, -1)
        waitReqCompl(client, status.getRequestId())

        # Remove the cloned disk (execute=0), should be successfull.
        status = client.remDisk(diskId, 0)
        refStatFile = "ref/ngamsRemDiskCmdTest_test_RemDiskDisk_1_1_ref"
        tmpStatFile = "tmp/ngamsRemDiskCmdTest_test_RemDiskDisk_1_1_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMDISK Command/no execution")

        # Remove the cloned disk (execute=1), should be successfull.
        status = client.remDisk(diskId, 1)
        refStatFile = "ref/ngamsRemDiskCmdTest_test_RemDiskDisk_1_2_ref"
        tmpStatFile = "tmp/ngamsRemDiskCmdTest_test_RemDiskDisk_1_2_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMDISK Command/execution")
示例#8
0
    def test_ArchiveCmd_Err_3_1(self):
        """
        Synopsis:
        Handling of corrupted HTTP response.

        Description:
        The purpose of the test is test that a corrupted HTTP response is
        properly handled by the C-Client/API.

        The response is corrupted such that it only contains a '\015\012'
        ({Slash r}{Slash n}).

        Expected Result:
        The corrupt HTTP response cannot be unpacked/interpreted as an
        XML document. This should be detected by the C-API and a proper
        error message returned.

        Test Steps:
        - Start special instance of the server class, which produces
          an illegal response.
        - Issue an ARCHIVE Command via the ngamsCClient.
        - Check that the output produced on stdout refers to the appropriate
          error message.

        Remarks:
        ...
        """

        # TODO: From V4.0, this test case produces the error:
        #
        # Error Code:     -4
        # Message:        Problem communicating with server
        #
        # - and not:
        #
        # Error Code:     -103
        # Message:        Invalid reply from data server
        #
        # - as for previous version.
        #
        # This should be investigated and resolved.

        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_IllegalResp")
        rmFile("tmp/ngamsServerTestIllegalResp_tmp")
        saveInFile("tmp/ngamsServerTestIllegalResp_tmp", "\015\012")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        out = _execCClient(unpackXmlStat=0,
                           pars=[["-port", "8888"], ["-cmd", "ARCHIVE"],
                                 ["-fileUri", "src/SmallFile.fits"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_ArchiveCmd_Err_3_1_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of corrupt server HTTP response in C-Client/API")
示例#9
0
    def test_RegisterCmd_1(self):
        """
        Synopsis:
        REGISTER Command/register single file compl. path.

        Description:
        Test handling of the REGISTER Command under normal circumstances.

        Expected Result:
        The REGISTER Command should be accepted by the server and should
        be executed successfully.

        Test Steps:
        - Start server.
        - Copy file onto NGAS Disk.
        - Submit REGISTER Command requesting to register the file copied over
          (wait=1).
        - Check response from the server that the request was successfully
          executed.
        - Check the DB info for the registered file.

        Remarks:
        ...
        """
        _, dbObj = self.prepExtSrv()
        srcFile = "src/SmallFile.fits"
        tmpSrcFile = "/tmp/ngamsTest/NGAS/" +\
                     "FitsStorage2-Main-3/saf/test/SmallFile.fits"
        checkCreatePath(os.path.dirname(tmpSrcFile))
        shutil.copy(srcFile, tmpSrcFile)
        tmpStatFile = sendExtCmd(8888, NGAMS_REGISTER_CMD,
                                 [["path", tmpSrcFile]])
        refStatFile = "ref/ngamsRegisterCmdTest_test_RegisterCmd_1_ref"
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status returned for REGISTER command")
        diskId = "tmp-ngamsTest-NGAS-FitsStorage2-Main-3"
        filePrefix = "ngamsRegisterCmdTest_test_RegisterCmd_1"
        fileInfoRef = "ref/" + filePrefix + "_FileInfo_ref"
        fileInfoTmp = "tmp/" + filePrefix + "_FileInfo_tmp"
        fileId = "TEST.2001-05-08T15:25:00.123"
        startTime = time.time()

        host_id = getHostName() + ":8888"
        while ((time.time() - startTime) < 10):
            tmpFileRes = dbObj.getFileInfoFromFileIdHostId(
                host_id, fileId, 1, diskId)
            if (tmpFileRes): break
        if not tmpFileRes:
            self.fail(
                "Couldn't get fileInfo result from database within 10 seconds")
        tmpFileObj = ngamsFileInfo.ngamsFileInfo().unpackSqlResult(tmpFileRes)
        saveInFile(fileInfoTmp, filterDbStatus1(tmpFileObj.dumpBuf()))
        self.checkFilesEq(fileInfoRef, fileInfoTmp,
                          "Incorrect info in DB for registered file")
示例#10
0
def _checkContDbSnapshot(testSuiteObj,
                         testCaseNo,
                         dataDirList,
                         waitEmptyCache = True,
                         filterContents = True):
    """
    Function to check the contents of a DB Snapshot file.

    testSuiteObj:   Reference to Test Suite Object (ngamsTestSuite).

    testCaseNo:     Test Case number (integer).

    dataDirList:    List of directories under the NGAS Root Mount Point
                    to check (list).

    Returns:        Void.
    """
    dirPat = "/tmp/ngamsTest/NGAS/%s/.db/NgasFiles.bsddb"
    cacheDirPat = "/tmp/ngamsTest/NGAS/%s/.db/cache"
    refFilePat = "ref/ngamsDbSnapShotTest_test_DbSnapshot_%d_%d.ref"
    count = 1
    startTime = time.time()
    for dataDir in dataDirList:
        # Wait till the DB Snapshot Cache Dir is empty.
        if (waitEmptyCache):
            cacheDir = cacheDirPat % dataDir
            startTime = time.time()
            while (((time.time() - startTime) < 10) and
                   (not os.path.exists(cacheDir))):
                time.sleep(0.200)
            startTime = time.time()
            while ((time.time() - startTime) < 20):
                tmpDbSnapshot = glob.glob(cacheDir + "/*")
                if (len(tmpDbSnapshot) == 0): break
                time.sleep(0.200)

        complName = dirPat % dataDir
        refFile = refFilePat % (testCaseNo, count)
        tmpFile = complName + ".dump"
        startTime = time.time()
        while ((not os.path.exists(complName)) and
               ((time.time() - startTime) < 10)):
            time.sleep(0.200)
        testSuiteObj.checkEqual(1, os.path.exists(complName),
                                "DB Snapshot missing: " + complName)
        out = subprocess.check_output(['ngamsDumpDbSnapshot', complName])
        if (filterContents):
            snapshotDump = _parseDbSnapshot(out)
        else:
            snapshotDump = out
        saveInFile(tmpFile, snapshotDump)
        testSuiteObj.checkFilesEq(refFile, tmpFile,
                                  "Incorrect contents of DB Snapshot")
        count += 1
示例#11
0
    def test_ServerLoad_3(self):
        """
        Synopsis:
        Test loading of specific configuration from DB.

        Description:
        Test that the NG/AMS Server is loading configuration from DB and
        initializing as expected without mixing up parameters from other
        configurations in the DB.

        Expected Result:
        The NG/AMS Server should load only parameters for the specified
        configuration Group ID and ignore other parameters in the DB.

        Test Steps:
        - Prepare two XML configurations and load them in the DB. Difference
          is that all attribute values of the second are set to value=0, which
          means that the server could not operate if mixing up parameters from
          the two.
        - Start server.
        - Archive file and check that the file was successfully archived.

        Remarks:
        ...
        """
        cfgName1 = "test_ServerLoad_1"
        cfgObj, _ = self.loadCfg(cfgName1)
        cfgFile = saveInFile(None, cfgObj.genXmlDoc(0))

        # For the second cfg. set all the DB Cfg. Group ID to a common value
        # + set all values to a non-sense value.
        cfgName2 = "test_ServerLoad_2"
        tmpCfg = db_aware_cfg("src/ngamsCfg.xml")
        for cfgKey in tmpCfg._getXmlDic().keys():
            if ((cfgKey[-1] != "]") and (cfgKey.find("Db[1]") == -1)):
                tmpCfg.storeVal(cfgKey, "0")
        tmpCfg.storeVal("NgamsCfg.Log[1].LocalLogFile",
                        "/tmp/ngamsTest/NGAS/log/LogFile.nglog", "0")
        tmpCfgFile = saveInFile(None, tmpCfg.genXmlDoc(0))
        self.loadCfg(cfgName2,
                     cfgFile=tmpCfgFile,
                     checkCfg=0,
                     delDbTbls=0,
                     dbCfgGroupIds=[0],
                     createDatabase=False)

        # Start server specifying 1st DB cfg.
        self.prepExtSrv(cfgFile=cfgFile, dbCfgName=cfgName1, clearDb=0)
        statObj = sendPclCmd().archive("src/SmallFile.fits")
        refStatFile = "ref/ngamsConfigHandlingTest_test_ServerLoad_3_1_ref"
        tmpStatFile = saveInFile(None, filterDbStatus1(statObj.dumpBuf()))
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect status " +\
                          "returned for Archive Push Request")
示例#12
0
    def test_RemFileCmd_2(self):
        """
        Synopsis:
        Missing file copies, REMFILE Command rejected.

        Description:
        The purpose of the Test Case is to verify that the REMFILE Command
        is rejected when it is attempted to remove files available in less
        than 3 copies in the archive. This both when specifying execute=0 and
        execute=1.

        Expected Result:
        The server should detect that the file requested to be REMFILE'd is
        not available on the system in at least 3 independent copies.

        Test Steps:
        - Start server.
        - Archive file.
        - Submit REMFILE Command to remove copy of file on Main Disk
          (execute=0).
        - Check on response from the server that the request was rejected.
        - Submit REMFILE Command to remove copy of file on Main Disk
          (execute=1).
        - Check on response from the server that the request was rejected.

        Remarks:
        TODO!: It is not check if an Email Notification is sent out listing
               files, which could not be removed because they were available
               in less than 3 copies.
        """
        self.prepExtSrv()
        client = sendPclCmd()

        # Archive file.
        client.archive("src/SmallFile.fits")

        # Remove the archived file (execute=0), should fail.
        fileId = "TEST.2001-05-08T15:25:00.123"
        diskId = "tmp-ngamsTest-NGAS-FitsStorage1-Main-1"
        status = client.remFile(diskId, fileId, 1, 0)
        refStatFile = "ref/ngamsRemFileCmdTest_test_RemFileCmd_2_1_ref"
        tmpStatFile = "tmp/ngamsRemFileCmdTest_test_RemFileCmd_2_1_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMFILE Command/no execution")

        # Remove the cloned file (execute=1), should fail.
        status = client.remFile(diskId, fileId, 1, 1)
        refStatFile = "ref/ngamsRemFileCmdTest_test_RemFileCmd_2_2_ref"
        tmpStatFile = "tmp/ngamsRemFileCmdTest_test_RemFileCmd_2_2_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMFILE Command/execution")
示例#13
0
    def test_RemFileCmd_1(self):
        """
        Synopsis:
        Test normal execution of the REMFILE Command.

        Description:
        Test the normal execution of the REMFILE Command, whereby a file is
        requested to the REMFILE'd which is available in at least 3 copies.

        Expected Result:
        The server should identify that the file requested to be removed is
        available in at least 3 copies and should accept the request.

        Test Steps:
        - Start server.
        - Archive file.
        - Clone Main Disk hosting archived file.
        - Submit REMFILE Command requesting to remove cloned file (execute=0).
        - Check on response from server that the request has been accepted.
        - Submit REMFILE Command requesting to remove cloned file (execute=1).
        - Check on response from server that the request has been accepted.

        Remarks:
        TODO!: It is not checked that the info for the file is actually
               removed from the DB and from the disk.
        """
        self.prepExtSrv(cfgProps=(('NgamsCfg.Server[1].RequestDbBackend',
                                   'memory'), ))
        client = sendPclCmd()

        # Archive a file + clone it to be able to execute the REMFILE Command.
        client.archive("src/SmallFile.fits")
        fileId = "TEST.2001-05-08T15:25:00.123"
        diskId = "tmp-ngamsTest-NGAS-FitsStorage1-Main-1"
        status = client.clone(fileId, diskId, 1)
        waitReqCompl(client, status.getRequestId())

        # Remove the cloned file (execute=0), should be successfull.
        status = client.remFile(diskId, fileId, 1, 0)
        refStatFile = "ref/ngamsRemFileCmdTest_test_RemFileCmd_1_1_ref"
        tmpStatFile = "tmp/ngamsRemFileCmdTest_test_RemFileCmd_1_1_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMFILE Command/no execution")

        # Remove the cloned file (execute=1), should be successfull.
        status = client.remFile(diskId, fileId, 1, 1)
        refStatFile = "ref/ngamsRemFileCmdTest_test_RemFileCmd_1_2_ref"
        tmpStatFile = "tmp/ngamsRemFileCmdTest_test_RemFileCmd_1_2_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMFILE Command/execution")
示例#14
0
    def test_RetrieveCmd_3(self):
        """
        Synopsis:
        Retrieve file from NGAS Cluster sub-node.

        Description:
        Test that a file stored on a sub-node is located and returned to the
        requestor by the contacted server acting as proxy is Proxy Mode is
        eneabled.

        Expected Result:
        The contacted server should locate the file, forward the request to
        the node hosting the file, and should send back the file to the
        requestor.

        Test Steps:
        - Start simulated cluster with master and sub-node.
        - Archive file onto sub-node.
        - Submit Retrieve Request to Master Node to retrieved the archived
          file.
        - Check the response from the Master Node.
        - Check that the file has been retrieved as expected.

        Remarks:
        ...
        """
        self.prepCluster((8000, 8011))
        # Archive file into sub-node (port=8011).
        sendPclCmd(port=8011).archive("src/TinyTestFile.fits")

        # Retrieve a file.
        trgFile = "tmp/test_RetrieveCmd_3_1_tmp"
        client = sendPclCmd(port=8000)
        status = client.retrieve("NCU.2003-11-11T11:11:11.111",
                                 targetFile=trgFile)

        # Check reply.
        refStatFile = "ref/ngamsRetrieveCmdTest_test_RetrieveCmd_3_1_ref"
        tmpStatFile = "tmp/ngamsRetrieveCmdTest_test_RetrieveCmd_3_1_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for RETRIEVE Command/Cluster " +\
                          "Retrieval")

        outFilePath = 'tmp/test_RetrieveCmd_3_1_tmp_unzip'
        with gzip.open(trgFile, 'rb') as gz, open(outFilePath, 'wb') as out:
            for data in iter(partial(gz.read, 1024), ''):
                out.write(data)

        # Check the retrieved file (checksum).
        refFile = "src/TinyTestFile.fits"
        self.checkFilesEq(outFilePath, refFile, "Retrieved file incorrect")
示例#15
0
    def test_WakeUpStatus_1(self):
        """
        Synopsis:
        Test that suspended server is woken up when
        STATUS?host_id=<Sub-Node> specifying that node is sent.

        Description:
        If a STATUS Command is send to a node requesting status from another
        node (Proxy Mode), and the target is suspended, the contacted node
        must wake up the suspended target node. The purpose of this test
        is to verify this use case.

        Expected Result:
        The contacted node should identify the target node as suspended,
        and should wake it up prior to forwarding the STATUS Command acting
        as proxy.

        Test Steps:
        - Start simulated cluster specifying that one node can suspend itself.
        - Wait till sub-node has suspended itself.
        - Send STATUS Command to the simulated master requesting status from
          the suspended sub-node.
        - Check the response to the STATUS Command.
        - Cross check that the suspended node is now woken up by sending
          a STATUS Command directly to the sub-node.

        Remarks:
        ...
        """
        cfgParDic = {"8001": [["%s.IdleSuspensionTime" % SUSP_EL, "5"]]}
        dbConObj = prepSimCluster(self, cfgParDic=cfgParDic)[masterNode][1]
        self.waitTillSuspended(dbConObj, subNode1, 30, susp_nodes)

        # 1. Send STATUS Command to sub-node using master as proxy.
        statObj = sendPclCmd(port=8000, auth=AUTH).\
                      get_status(NGAMS_STATUS_CMD, pars = [["host_id", subNode1]])
        statBuf = filterOutLines(statObj.dumpBuf(), ["Date:", "Version:"])
        tmpStatFile = saveInFile(None, statBuf)
        refStatFile = "ref/ngamsIdleSuspensionTest_test_WakeUpStatus_1_1_ref"
        refStatFile = saveInFile(None, loadFile(refStatFile) % getHostName())
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Sub-node not woken up as expected")

        # 2. Double-check that sub-node is no longer suspended.
        statObj = sendPclCmd(port=8001, auth=AUTH).status()
        statBuf = filterOutLines(statObj.dumpBuf(), ["Date:", "Version:"])
        tmpStatFile = saveInFile(None, statBuf)
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Sub-node not woken up as expected")

        # Clean up.
        self.markNodesAsUnsusp(dbConObj, susp_nodes)
示例#16
0
    def test_RemDiskCmd_2(self):
        """
        Synopsis:
        Missing file copies, REMDISK Command rejected.

        Description:
        If there are not enough copies of files stored on a disk requested
        to be REMDISK'ed, the server should reject the request indicating
        the problem in the response.

        If an Email Notification List has been specified, the files in
        question, should be reported via email.

        Expected Result:
        The REMDISK Command should be rejected by the server, which should
        detect that there are files on the disk requested to be REMDISK'ed,
        which are not available in the system in 3 independent copies.

        Test Steps:
        - Start server.
        - Archive file.
        - Submit REMDISK to remove Main Disk hosting the archived file
          (execute=0).
        - Check on the response that the command is rejected by the server.
        - Submit REMDISK to remove Main Disk hosting the archived file
          (execute=1).
        - Check on the response that the command is rejected by the server.

        Remarks:
        ...
        """
        self.prepExtSrv()
        client = sendPclCmd()
        client.archive("src/SmallFile.fits")

        # Remove the cloned disk (execute=0), should fail.
        diskId = "tmp-ngamsTest-NGAS-FitsStorage1-Main-1"
        status = client.remDisk(diskId, 0)
        refStatFile = "ref/ngamsRemDiskCmdTest_test_RemDiskDisk_2_1_ref"
        tmpStatFile = "tmp/ngamsRemDiskCmdTest_test_RemDiskDisk_2_1_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMDISK Command/no execution")

        # Remove the cloned disk (execute=1), should fail.
        status = client.remDisk(diskId, 1)
        refStatFile = "ref/ngamsRemDiskCmdTest_test_RemDiskDisk_2_2_ref"
        tmpStatFile = "tmp/ngamsRemDiskCmdTest_test_RemDiskDisk_2_2_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for REMDISK Command/execution")
示例#17
0
    def test_WakeUpStatus_2(self):
        """
        Synopsis:
        Test that suspended server is woken up when STATUS?file_access is
        issued, specifying a file on a suspended sub-node.

        Description:
        The purpose of the test is to verify that a suspended sub-node is
        woken up by a master node acting as proxy if a STATUS?file_id is
        send pointing to a file on the suspended sub-node.

        Expected Result:
        The suspended sub-node should be woken up by the master node which
        after the suspended sub-node has come Online should forward the
        request which is executed on the sub-node and the result send back to
        the client through the master node.

        Test Steps:
        - Prepare simulated cluster with unit, which suspends itself.
        - Archive 3 files onto sub-node.
        - Wait till sub-node has suspended itself.
        - Send a STATUS?file_id request to the Master Node specifying one
          of the files previously archived.
        - Check the result returned from the sub-node via the Master Node.

        Remarks:
        ...
        """
        cfgParDic = {"8001": [["%s.IdleSuspensionTime" % SUSP_EL, "5"]]}
        dbConObj = prepSimCluster(self, cfgParDic=cfgParDic)[masterNode][1]

        # Archive some files on the two nodes and wait till sub-node
        # has suspended itself.
        sendPclCmd(port=8000, auth=AUTH).archive("src/TinyTestFile.fits")
        sendPclCmd(port=8000, auth=AUTH).archive("src/SmallFile.fits")
        sendPclCmd(port=8001, auth=AUTH).archive("src/SmallFile.fits")
        self.waitTillSuspended(dbConObj, subNode1, 20, susp_nodes)

        # Retrieve information about the file on the suspended sub-node.
        fileId = "TEST.2001-05-08T15:25:00.123"
        statObj = sendPclCmd(port=8000, auth=AUTH).\
                  get_status(NGAMS_STATUS_CMD, pars=[["file_access", fileId]])
        statBuf = filterOutLines(statObj.dumpBuf(), ["Date:", "Version:"])
        tmpStatFile = saveInFile(None, statBuf)
        refStatFile = "ref/ngamsIdleSuspensionTest_test_WakeUpStatus_2_1_ref"
        refStatFile = saveInFile(None, loadFile(refStatFile) %\
                                 (getHostName(), getHostName()))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Unexpected reply to STATUS?file_access request")
示例#18
0
    def test_RetrieveCmd_1(self):
        """
        Synopsis:
        Retrieve file from server hosting the file.

        Description:
        The purpose of the test is to test the case where it is attempted
        to retrieve an archived file directly from the unit hosting the file.

        Expected Result:
        The server should locate the file and send it back to the requestor.

        Test Steps:
        - Start server.
        - Archive FITS file.
        - Retrieve the file and store it in a local file.
        - Check reply from the server indiates that the request was handled
          successfully.
        - Check that the file on disk has been successfully retrieved.

        Remarks:
        ...
        """
        self.prepExtSrv()
        client = sendPclCmd()
        client.archive("src/SmallFile.fits")

        # Retrieve the file.
        trgFile = "tmp/test_RetrieveCmd_1_1_tmp"
        outFilePath = "tmp/SmallFile.fits"
        status = client.retrieve("TEST.2001-05-08T15:25:00.123",
                                 targetFile=trgFile)
        unzip(trgFile, outFilePath)

        # Check reply.
        refStatFile = "ref/ngamsRetrieveCmdTest_test_RetrieveCmd_1_1_ref"
        tmpStatFile = "tmp/ngamsRetrieveCmdTest_test_RetrieveCmd_1_1_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for RETRIEVE Command/Normal " +\
                          "Execution")

        # Check file retrieved.
        self.checkFilesEq("src/SmallFile.fits", outFilePath,
                          "Retrieved file incorrect")
示例#19
0
    def test_too_many_requests(self):

        saveInFile("tmp/handleHttpRequest_tmp", "handleHttpRequest_Block5secs")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack",
                        cfgProps=(('NgamsCfg.Server[1].MaxSimReqs', '2'), ))

        # Fire off two clients, each takes 5 seconds to finish
        cl1, cl2 = sendPclCmd(), sendPclCmd()
        threading.Thread(target=cl1.online).start()
        threading.Thread(target=cl2.online).start()

        # The third one should not pass through
        # (assuming that 2 seconds were enough for the two clients
        # to connect and be busy waiting for their reply)
        time.sleep(2)
        resp = ngamsHttpUtils.httpGet('127.0.0.1', 8888, 'ONLINE')
        with contextlib.closing(resp):
            self.assertEqual(NGAMS_HTTP_SERVICE_NA, resp.status)
示例#20
0
    def test_ServerLoad_2(self):
        """
        Synopsis:
        Test that the NG/AMS Server is loading configuration from DB and
        initializing as expected.

        Description:
        The purpose of this Test Case is to verify that the NG/AMS Server
        can be initialized properly by loading the configuration from the
        NGAS DB. The parameter disabling handling of Archive Requests is
        set to 0. It is checked that the server after initialization,
        rejects Archive Requests.

        Expected Result:
        The NG/AMS Server should initialize and select disabling of handling
        of Archive Requests. Submitting Archive Requests to the server
        should result in a rejection of the request.

        Test Steps:
        - Create an NG/AMS XML Configuration where handling of Archive Requests
          is disabled.
        - Load this into the DB.
        - Start instance of the NG/AMS Server specifying to use the previously
          loaded configuration.
        - Issue an Archive Request and verify that it is rejected.

        Remarks:
        ...
        """
        cfgName = "test_ServerLoad_2"
        tmpCfg = db_aware_cfg("src/ngamsCfg.xml").\
                 storeVal("NgamsCfg.Permissions[1].AllowArchiveReq", "0",
                          "Permissions-Test")
        cfgFile = saveInFile(None, tmpCfg.genXmlDoc(0))
        cfgObj, _ = self.loadCfg(cfgName, cfgFile=cfgFile)
        cfgFile = saveInFile(None, str(cfgObj.genXmlDoc()))
        self.prepExtSrv(cfgFile=cfgFile, dbCfgName=cfgName, clearDb=0)

        # Archive a file, should be rejected.
        statObj = sendPclCmd().archive("src/SmallFile.fits")
        refStatFile = "ref/ngamsConfigHandlingTest_test_ServerLoad_2_1_ref"
        tmpStatFile = saveInFile(None, filterDbStatus1(statObj.dumpBuf()))
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect status " +\
                          "returned for Archive Push Request")
示例#21
0
    def test_Load_1(self):
        """
        Synopsis:
        Test Purpose: Load configuration into DB.

        Description:
        The purpose of this Test Case is to test that the NG/AMS Configuration
        can be loaded properly from an XML configuration document into the
        NGAS DB.

        Expected Result:
        The XML based NG/AMS Configuration should be loaded into the NGAS DB.

        Test Steps:
        - Load configuration into instance of ngamsConfig and write it to
          the NGAS DB.
        - Load the previously loaded configuration from the DB into an object
          and dump this into an NG/AMS XML Configuration.
        - Verify that the contents is as expected after loading into the DB
          and dumping from the DB into an ASCII format in the NGAS XML
          Dictionary format.

        Remarks:
        ...
        """
        cfgObj1, dbObj = self.loadCfg("test_Load_1")

        # Load + check the configuration from the DB.
        cfgObj2 = ngamsConfig.ngamsConfig()
        # Dump as XML Dictionary.
        cfgObj2.loadFromDb("test_Load_1", dbObj)
        refFile = "ref/ngamsConfigHandlingTest_test_Load_1_1_ref"
        cleanXmlDoc = _cleanXmlDoc(cfgObj2.dumpXmlDic(), r'^NgamsCfg.Db\[1\]')
        tmpStatFile = saveInFile(None, cleanXmlDoc)
        self.checkFilesEq(refFile, tmpStatFile, "Incorrect contents of " +\
                          "XML Dictionary of cfg. loaded from DB")
        # Dump as XML Document.
        refFile = "ref/ngamsConfigHandlingTest_test_Load_1_2_ref"
        tmpStatFile = saveInFile(None, without_db_element(cfgObj2.genXmlDoc()))
        self.checkFilesEq(refFile, tmpStatFile, "Incorrect contents of " +\
                          "XML Document of cfg. loaded from DB")
示例#22
0
    def test_RetrieveCmd_2(self):
        """
        Synopsis:
        Attempt to retrieve non-existing file (wrong version).

        Description:
        Test the case where it is attempted to retrieve a non-exiting file.
        An appropriate error response should be generated.

        Expected Result:
        The server should identify that the file is not found in the NGAS
        Archive and should return a response indicating this.

        Test Steps:
        - Start server.
        - Archive FITS file.
        - Retrieve file with same File ID as archived file but with another
          version than the one allocated to the file.
        - Check the error response from the server.

        Remarks:
        ...
        """
        self.prepExtSrv()
        client = sendPclCmd()
        client.archive("src/SmallFile.fits")

        # Retrieve the file.
        trgFile = "tmp/test_RetrieveCmd_1_1_tmp"
        status = client.retrieve("TEST.2001-05-08T15:25:00.123",
                                 fileVersion=2,
                                 targetFile=trgFile)

        # Check reply.
        refStatFile = "ref/ngamsRetrieveCmdTest_test_RetrieveCmd_2_1_ref"
        tmpStatFile = "tmp/ngamsRetrieveCmdTest_test_RetrieveCmd_2_1_tmp"
        saveInFile(tmpStatFile, filterDbStatus1(status.dumpBuf(0, 1, 1)))
        self.checkFilesEq(refStatFile, tmpStatFile,
                          "Incorrect status for RETRIEVE Command/Normal " +\
                          "Execution")
示例#23
0
    def test_RetrieveCmd_Err_1_2(self):
        """
        Synopsis:
        Issue RETRIEVE Command/server dies during initial handling.

        Description:
        Check that the situation where the server dies during the initial
        handling of a Retrieve Request is correctly handled by the C-API.

        Expected Result:
        The C-API should detect that the server died (=broken socket
        connection) and should produce the appropriate error code, which is
        printed on stdout by the ngamsCClient.

        Test Steps:
        - Start a special instance of the server, which kills itself
          when receiving a RETRIEVE Command.
        - Archive a file.
        - Issue a RETRIEVE Command to retrieve the archived file.
        - Verify that the proper output is produced by ngamsCClient indicating
          the problem.

        Remarks:
        ...
        """
        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_SrvCrash2")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        out =\
            _execCClient(unpackXmlStat = 0,
                         pars = [["-port", "8888"],
                                 ["-cmd", "RETRIEVE"],
                                 ["-fileId", "TEST.2001-05-08T15:25:00.123"],
                                 ["-timeOut", "10"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_RetrieveCmd_Err_1_2_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of timeout of Retrieve Request in C-Client/API")
示例#24
0
    def test_NormalExec_1(self):
        """
        Synopsis:
        Normal execution of CHECKFILE Command.

        Description:
        The purpose of this Text Case is to test the normal/standard
        execution of the CHECKFILE Command.

        Expected Result:
        The CHECKFILE Command should be accepted and executed successfully
        by the server on an existing file.

        Test Steps:
        - Start NG/AMS Server.
        - Archive a file successfully.
        - Check the file specifying Disk ID/File Id/File Version.
        - Check the the result returned by the NG/AMS Server is as expected.

        Remarks:
        ...
        """
        self.prepExtSrv()
        sendPclCmd().archive("src/SmallFile.fits")
        diskId = "tmp-ngamsTest-NGAS-FitsStorage1-Main-1"
        fileId = "TEST.2001-05-08T15:25:00.123"
        statObj = sendPclCmd(port=8888).get_status(NGAMS_CHECKFILE_CMD,
                                                   pars=[["disk_id", diskId],
                                                         ["file_id", fileId],
                                                         ["file_version",
                                                          "1"]])
        refStatFile = "ref/ngamsCheckFileCmdTest_test_NormalExec_1_1_ref"
        refStatFile = saveInFile(
            None,
            loadFile(refStatFile) % ("%s:%d" % (getHostName(), 8888)))
        tmpStatFile = saveInFile(None, statObj.getMessage())
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect info in " +\
                          "STATUS Command XML Status Document")
示例#25
0
    def test_RetrieveCmd_Err_1_1(self):
        """
        Synopsis:
        Issue RETRIEVE Command/request times out.

        Description:
        The purpose of the test is to verify that the situation where a
        Retrieve Request times out is correctly handled by the C-API.

        Expected Result:
        After the specified timeout is reached, the appropriate error code
        is returned to the client.

        Test Steps:
        - Start special instance of the server, which blocks on a Retrieve
          Request (no response send).
        - Issue a Retrieve Request via the ngamsCClient with timeout 10s.
        - Verify that after 10s the correct error code is returned by the
          C-API (printed by ngamsCClient on stdout).

        Remarks:
        ...
        """
        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_AccArchiveBlock2")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        sendPclCmd(port=8888).archive("src/SmallFile.fits")
        out =\
            _execCClient(unpackXmlStat = 0,
                         pars = [["-port", "8888"],
                                 ["-cmd", "RETRIEVE"],
                                 ["-fileId", "TEST.2001-05-08T15:25:00.123"],
                                 ["-timeOut", "10"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_RetrieveCmd_Err_1_1_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of timeout of Retrieve Request in C-Client/API")
示例#26
0
    def test_ArchiveCmd_Err_3_3(self):
        """
        Synopsis:
        Issue ARCHIVE Command/server sends back a nonsense HTTP response.

        Description:
        The purpose of the test is test that a corrupted HTTP response is
        properly handled by the C-Client/API.

        The response is corrupted such that it contains 'noise'.

        Expected Result:
        The C-API should detect the illegally formatted response and return
        the correct error code.

        Test Steps:
        - Start special instance of the server that generates a non-sense
          HTTP response.
        - Issue an Archive Request via the ngamsCClient.
        - Check that the proper error message is produced by the ngamsCClient

        Remarks:
        ...
        """
        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_IllegalResp")
        rmFile("tmp/ngamsServerTestIllegalResp_tmp")
        saveInFile("tmp/ngamsServerTestIllegalResp_tmp", "f-423hcqfe-0")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        out = _execCClient(unpackXmlStat=0,
                           pars=[["-port", "8888"], ["-cmd", "ARCHIVE"],
                                 ["-fileUri", "src/SmallFile.fits"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_ArchiveCmd_Err_3_3_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of corrupt server HTTP response in C-Client/API")
示例#27
0
    def test_ArchiveCmd_Err_2(self):
        """
        Synopsis:
        Issue ARCHIVE Command/server crashes (broken socket connection).

        Description:
        The purpose of the test is to verify the correct handling/behavior
        of the C-Client/API in the case the socket connection to the server
        breaks.

        Expected Result:
        During the request handling the socket connection is provoked to break
        and the C-Client/API should detect this and shoudl produce the proper
        error message.

        Test Steps:
        - Start special instance of the server which makes itself crash when
          a request is received (to simulate a broken socket connection).
        - Submit an ARCHIVE Command via the C-Client/API (small file).
        - Check the result produced by the ngamsCClient on stdout that this
          is as expected.

        Remarks:
        ...

        """
        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_SrvCrash1")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        out = _execCClient(unpackXmlStat=0,
                           pars=[["-port", "8888"], ["-cmd", "ARCHIVE"],
                                 ["-fileUri", "src/SmallFile.fits"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_ArchiveCmd_Err_2_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of crash of server in C-Client/API")
示例#28
0
    def test_ArchiveCmd_Err_5_1(self):
        """
        Synopsis:
        Issue ARCHIVE Command/socket breaks while writing data on it.

        Description:
        The purpose of the test is to verify that the C-API handles
        properly the situation where the socket connection breaks while
        data is being written on it (during an Archive Push Request).

        Expected Result:
        The C-API should detect that the write socket connection breaks, and
        should produce the appropriate error message.

        Test Steps:
        - Start special instance of server which terminates itself while
          the client writes the data to the server.
        - Issue Archive Push Request with a big file to the server.
        - Verify that the proper error response is produced by the C-API.

        Remarks:
        ...
        """
        rmFile("tmp/reqCallBack_tmp")
        saveInFile("tmp/reqCallBack_tmp", "reqCallBack_SrvCrash1")
        self.prepExtSrv(srvModule="ngamsSrvTestDynReqCallBack")
        cpFile("src/WFI-TEST.fits.Z", "tmp/WFI-TEST_tmp.fits.Z")
        rmFile("tmp/WFI-TEST_tmp.fits")
        subprocess.check_call(['uncompress', 'tmp/WFI-TEST_tmp.fits.Z'])
        out = _execCClient(unpackXmlStat=0,
                           pars=[["-port", "8888"], ["-cmd", "ARCHIVE"],
                                 ["-fileUri", "tmp/WFI-TEST_tmp.fits"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_ArchiveCmd_Err_5_1_ref"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of broken write socket in C-Client/API")
示例#29
0
    def test_CloneCmd_2(self):
        """
        Synopsis:
        Normal execution of CLONE Command specifying disk_id (async=1).

        Description:
        Clone an entire disk and check that the Clone Request was successfully
        handled.

        Expected Result:
        The 10 files on the disk specified to be cloned should be cloned
        onto the selected Target Disk.

        Test Steps:
        - Start normal NG/AMS Server.
        - Archive small FITS file 10 times.
        - Flush email queue.
        - Issue Clone Request.
        - Wait for Clone Request to terminate.
        - Check that the Clone Status Report indicates that the files were
          cloned as expected.

        Remarks:
        TODO: Re-implement using _execCloneTest().
        """
        srcFile = "src/SmallFile.fits"
        self.prepExtSrv(cfgProps=(('NgamsCfg.Server[1].RequestDbBackend',
                                   'memory'), ))
        client = sendPclCmd()
        for n in range(10):
            client.archive(srcFile)
        flushEmailQueue()
        testUserEmail = getpass.getuser() + "@" + ngamsLib.getCompleteHostName(
        )
        diskId = "tmp-ngamsTest-NGAS-FitsStorage1-Main-1"
        statObj = client.get_status(NGAMS_CLONE_CMD,
                                    pars=[["disk_id", diskId], ["async", "1"],
                                          ["notif_email", testUserEmail]])
        waitReqCompl(client, statObj.getRequestId(), 20)

        if _checkMail:
            mailCont = getEmailMsg(
                ["NGAS Host:", "Total proc", "Handling time"])
            refStatFile = "ref/ngamsCloneCmdTest_test_CloneCmd_2_ref"
            tmpStatFile = saveInFile(None, _sortRepFileList(mailCont))
            self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect/missing " +\
                              "CLONE Status Notification Email Msg")
示例#30
0
    def test_RetrieveCmd_Err_1_3(self):
        """
        Synopsis:
        Issue RETRIEVE Command/server dies (connection broken)
        while the server is sending the data across.

        Description:
        The purpose of the test is to verify that the C-Client/API handle
        properly the situation where the socket connection where the server
        is writing data to the client breaks.

        Expected Result:
        The C-API should detect the problem, and that the file has been
        received incomplete and should return the proper error code, which
        is written by ngamsCClient on stdout.

        Test Steps:
        - Start special instance of the server class, which terminates itself
          while returned requested data.
        - Archive a file.
        - Retrieve the file.
        - Check that the proper error response is created on stdout by
          ngamsCClient.

        Remarks:
        ...
        """
        self.prepExtSrv(srvModule="ngamsSrvTestBrokSockRetrieve")
        sendPclCmd().archive("src/SmallFile.fits")
        out = _execCClient(unpackXmlStat=0,
                           pars=[["-port", "8888"], ["-cmd", "RETRIEVE"],
                                 ["-fileId", "TEST.2001-05-08T15:25:00.123"],
                                 ["-timeOut", "5"]])
        tmpStatFile = saveInFile(None, filterOutLines(out, ["Host"]))
        refStatFile = "ref/ngamsCClientTest_test_RetrieveCmd_Err_1_3"
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect handling " +\
                          "of broken read socket in C-Client/API")