コード例 #1
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")
コード例 #2
0
    def test_CloneCmd_1(self):
        """
        Synopsis:
        Normal execution of CLONE Command/clone one file/async=1.

        Description:
        Test normal execution of the CLONE Command whereby async=1.

        Expected Result:
        An immediate response should be returned indicating that the
        CLONE Command has been accepted for execution. The Clone Status
        Report should be send out indicating that the file was cloned.

        Test Steps:
        - Start 1 NG/AMS Server.
        - Archive file 2 times.
        - Clone one file specifying disk_id, file_id and file_version + async=1.
        - Check that the immediate response is correctly returned.
        - Wait for the execution of the CLONE Command to finish.
        - Check that the Request Info in the NG/AMS Server indicates that the
          Clone Request finished.
        - Check that the cloned file has arrived on the Target Disk.
        - Check that the DB info has been updated as it should.

        Remarks:
        TODO: Re-implement using _execCloneTest().
        """
        srcFile = "src/SmallFile.fits"
        cfgObj, dbObj = self.prepExtSrv(cfgProps=(('NgamsCfg.Server[1].RequestDbBackend', 'memory'),))
        client = sendPclCmd()
        for n in range(2): client.archive(srcFile)
        flushEmailQueue()
        testUserEmail = getpass.getuser()+"@"+ngamsLib.getCompleteHostName()
        statObj = client.get_status(NGAMS_CLONE_CMD,
                                    pars = [["disk_id", srcDiskId],
                                            ["file_id", nmuFileId],
                                            ["file_version", "1"],
                                            ["async", "1"],
                                            ["notif_email", testUserEmail]])
        refStatFile = "ref/ngamsCloneCmdTest_test_CloneCmd_1_1_ref"
        tmpStatFile = saveInFile(None, filterDbStatus1(statObj.dumpBuf()))
        self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect status for " +\
                          "CLONE command/successfull cloning")

        finalStatObj = waitReqCompl(client, statObj.getRequestId())
        complPer = str(finalStatObj.getCompletionPercent())
        self.checkEqual("100.0", complPer,
                        genErrMsgVals("Incorrect Request Status for CLONE " +\
                                      "Command/Completion Percent", "100.0",
                                      complPer))

        if _checkMail:
            mailCont = getEmailMsg(["NGAS Host:", "Total proc", "Handling time"])
            tmpStatFile = "tmp/ngamsCloneCmdTest_test_CloneCmd_1_tmp"
            refStatFile = "ref/ngamsCloneCmdTest_test_CloneCmd_1_ref"
            saveInFile(tmpStatFile, mailCont)
            self.checkFilesEq(refStatFile, tmpStatFile, "Incorrect/missing " +\
                              "CLONE Status Notification Email Msg")

        tmpFitsFile = "/tmp/ngamsTest/NGAS/FitsStorage2-Main-3/saf/" +\
                      "2001-05-08/1/TEST.2001-05-08T15:25:00.123.fits.gz"

        unzippedTmp = genTmpFilename()
        unzip(tmpFitsFile, unzippedTmp)
        self.checkFilesEq(srcFile, unzippedTmp, "Incorrect cloned file generated")

        diskId = "tmp-ngamsTest-NGAS-FitsStorage2-Main-3"
        filePrefix = "ngamsCloneCmdTest_test_CloneCmd_1"
        fileInfoRef = "ref/" + filePrefix + "_FileInfo_ref"
        fileInfoTmp = "tmp/" + filePrefix + "_FileInfo_tmp"
        fileInfo = ngamsFileInfo.\
                   ngamsFileInfo().read(getHostName() + ":8888",
                                        dbObj, "TEST.2001-05-08T15:25:00.123",
                                        1, diskId)
        saveInFile(fileInfoTmp, filterDbStatus1(fileInfo.dumpBuf()))
        self.checkFilesEq(fileInfoRef, fileInfoTmp, "Incorrect info in DB " +\
                          "for cloned file")
コード例 #3
0
def _execCloneTest(testObj,
                   testData,
                   refStatFile):
    """
    Execute the Clone Command Test based on the given input data. There is
    always waited for command execution.

    A more thorough test (using async=1) is implemented in test_CloneCmd_1 and
    test_CloneCmd_2 (testing also the Email Notification in connection with the
    CLONE Command).

    testData:       List with test information:

                      [<Disk ID>, <File ID>, <File Ver>, <Trg Disk ID>,
                       <Subnode (0|1)>]                                 (list)

    refStatFile:    Name of reference file (string).

    Returns:        Void.
    """
    diskId  = testData[0]
    fileId  = testData[1]
    fileVer = testData[2]
    trgDisk = testData[3]
    subNode = testData[4]
    if (subNode):
        testObj.prepCluster((8000, 8011))
        clNcu = sendPclCmd(port=8011)
    else:
        testObj.prepExtSrv(port=8000)
    clMnu = sendPclCmd(port=8000)
    for n in range(5):
        statObj = clMnu.archive("src/SmallFile.fits")
        if (subNode): clNcu.archive("src/TinyTestFile.fits")
    cmdPars = []
    if (diskId):  cmdPars.append(["disk_id", diskId])
    if (fileId):  cmdPars.append(["file_id", fileId])
    if (fileVer): cmdPars.append(["file_version", fileVer])
    if (trgDisk): cmdPars.append(["target_disk_id", trgDisk])
    cmdPars.append(["async", "0"])
    cmdPars.append(["notif_email", getpass.getuser() + "@" +\
                    ngamsLib.getCompleteHostName()])
    flushEmailQueue()
    statObj = clMnu.get_status(NGAMS_CLONE_CMD, pars = cmdPars)

    # Check returned status.
    tmpStatFile = saveInFile(None, filterDbStatus1(statObj.dumpBuf(0, 1, 1)))
    errMsg = "Executed CLONE Command: Disk ID: %s, File ID: %s, " +\
             "File Version: %s, Target Disk: %s. Message: %s"
    testObj.checkFilesEq(refStatFile + "_1_ref", tmpStatFile, errMsg %
                         (str(diskId), str(fileId), str(fileVer), str(trgDisk),
                          str(statObj.getMessage())))

    if _checkMail:
        # Check Email Notification Message.
        mailCont = getEmailMsg(["NGAS Host:", "Total proc", "Handling time"])
        mailCont = _sortRepFileList(mailCont)
        tmpStatFile = saveInFile(None, mailCont)
        saveInFile(tmpStatFile, mailCont)
        testObj.checkFilesEq(refStatFile + "_2_ref", tmpStatFile, errMsg %
                             (str(diskId), str(fileId), str(fileVer),
                              str(trgDisk), "Illegal CLONE Command Email " +\
                              "Notification Message"))