Exemple #1
0
    def test_hashverify_atime_no_reset(self):
        """
        1) Create a file
        2) hashcreate on it
        3) Set the access time into the past (touch -a t yyyymmddHHMM.SS ...)
        4) hashverify with atime reset turned OFF
        5) Get the access time -- it should be near the present
        6) remove the file
        """
        try:
            filename = self.plist[0]
            h = hpss.HSI(reset_atime=False)
            h.hashcreate(filename)

            # set the access time into the past
            past = util.epoch("2001.0203 04:05:06")
            h.touch(filename, when=past)

            # hashverify
            h.hashverify(filename)

            # check the atime -- it should be recent
            atime = h.access_time(filename)
            delta = time.time() - atime
            self.assertTrue(delta < 60,
                            "Expected a recent time, got '%s'" %
                            util.ymdhms(atime))
        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))
Exemple #2
0
    def test_hashverify_atime_reset(self):
        """
        1) Use file /home/tpb/hic_test/hashable1
        2) hashcreate on it
        3) Set the access time into the past (touch -a t yyyymmddHHMM.SS ...)
        4) hashverify with atime reset turned on
        5) Get the access time -- it should be the same as was set in step 3
        """
        try:
            filename = self.plist[0]
            h = hpss.HSI(reset_atime=True)

            # give it a hash
            h.hashcreate(filename)

            # set the access time into the past
            past = util.epoch("2001.0203 04:05:06")
            h.touch(filename, when=past)

            # hashverify
            h.hashverify(filename)

            # check the atime -- it should be old
            atime = h.access_time(filename)
            self.expected(util.ymdhms(past), util.ymdhms(atime))
        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))
Exemple #3
0
    def test_hashcreate_atime_no_reset(self):
        """
        1) use file /home/tpb/hic_test/hashable1
        2) delete the file's hash if it has one
        3) Set the access time into the past (touch -a t yyyymmddHHMM.SS ...)
        4) hashcreate with atime reset turned OFF
        5) Get the access time -- it should be near the present
        """
        try:
            filename = self.plist[0]
            h = hpss.HSI(reset_atime=False)

            # delete the file's hash if it has one
            hash = h.hashlist(filename)
            if "(none)" not in hash:
                h.hashdelete(filename)

            # set the file's atime into the past
            past = util.epoch("2001.0203 04:05:06")
            h.touch(filename, when=past)

            # give the file a hash
            h.hashcreate(filename)

            # check the atime -- it should be recent
            atime = h.access_time(filename)
            delta = time.time() - atime
            self.assertTrue(delta < 10,
                            "Expected a recent time, got '%s'" %
                            util.ymdhms(atime))
        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))
Exemple #4
0
    def test_hashcreate_atime_reset(self):
        """
        1) use file /home/tpb/hic_test/hashable1
        2) if it has a hash, delete it
        3) Set the access time into the past (touch -a t yyyymmddHHMM.SS ...)
        4) hashcreate with atime reset turned on (set when opening HSI)
        5) Get the access time -- it should be the same as was set in step 2
        """
        try:
            filename = self.plist[0]
            h = hpss.HSI(reset_atime=True)

            # delete the file's hash if it has one
            hash = h.hashlist(filename)
            if "(none)" not in hash:
                h.hashdelete(filename)

            # set the atime into the past
            past = util.epoch("2001.0203 04:05:06")
            h.touch(filename, when=past)

            # create a hash
            h.hashcreate(filename)

            # check the atime -- it should be way in the past
            atime = h.access_time(filename)
            self.expected(util.ymdhms(past), util.ymdhms(atime))

        except hpss.HSIerror as e:
            if MSG.hpss_unavailable in str(e):
                pytest.skip(str(e))
Exemple #5
0
 def test_epoch(self):
     """
     util.epoch() converts a date string matching one of a list of formats
     to an epoch time.
     """
     self.dbgfunc()
     self.expected(1388638799, util.epoch("2014.0101 23:59:59"))
     self.expected(1388638799, util.epoch("2014.0101.23.59.59"))
     self.expected(1388638740, util.epoch("2014.0101 23:59"))
     self.expected(1388638740, util.epoch("2014.0101.23.59"))
     self.expected(1388635200, util.epoch("2014.0101 23"))
     self.expected(1388635200, util.epoch("2014.0101.23"))
     self.expected(1388552400, util.epoch("2014.0101"))
     self.expected(1388552399, util.epoch("1388552399"))
     self.assertRaisesMsg(util.HpssicError,
                          "The date '' does not match any of the formats:",
                          util.epoch, "")
 def test_epoch(self):
     """
     util.epoch() converts a date string matching one of a list of formats
     to an epoch time.
     """
     self.dbgfunc()
     self.expected(1388638799, util.epoch("2014.0101 23:59:59"))
     self.expected(1388638799, util.epoch("2014.0101.23.59.59"))
     self.expected(1388638740, util.epoch("2014.0101 23:59"))
     self.expected(1388638740, util.epoch("2014.0101.23.59"))
     self.expected(1388635200, util.epoch("2014.0101 23"))
     self.expected(1388635200, util.epoch("2014.0101.23"))
     self.expected(1388552400, util.epoch("2014.0101"))
     self.expected(1388552399, util.epoch("1388552399"))
     self.assertRaisesMsg(util.HpssicError,
                          "The date '' does not match any of the formats:",
                          util.epoch,
                          "")