16319: Count Utimes stats.
authorTom Clegg <tom@tomclegg.ca>
Wed, 20 May 2020 13:59:00 +0000 (09:59 -0400)
committerTom Clegg <tom@tomclegg.ca>
Wed, 20 May 2020 13:59:00 +0000 (09:59 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

services/keepstore/unix_volume.go
services/keepstore/unix_volume_test.go

index 7af058ae57727123bc56ae135174fa3851748264..5026e2d32558e085886ba119cf0b664bfbc58473 100644 (file)
@@ -304,6 +304,8 @@ func (v *UnixVolume) WriteBlock(ctx context.Context, loc string, rdr io.Reader)
        // avoid this by setting the output file's timestamps
        // explicitly, using a higher resolution clock.
        ts := time.Now()
+       v.os.stats.TickOps("utimes")
+       v.os.stats.Tick(&v.os.stats.UtimesOps)
        if err = os.Chtimes(tmpfile.Name(), ts, ts); err != nil {
                err = fmt.Errorf("error setting timestamps on %s: %s", tmpfile.Name(), err)
                v.os.Remove(tmpfile.Name())
index 7777363b9d13815ab3036ae916a2c0f6989eb95f..5a3a536944daa5b8012bc0b2afbf8b6932862364 100644 (file)
@@ -405,13 +405,13 @@ func (s *UnixVolumeSuite) TestStats(c *check.C) {
        c.Check(stats(), check.Matches, `.*"OutBytes":3,.*`)
        c.Check(stats(), check.Matches, `.*"CreateOps":1,.*`)
        c.Check(stats(), check.Matches, `.*"OpenOps":0,.*`)
-       c.Check(stats(), check.Matches, `.*"UtimesOps":0,.*`)
+       c.Check(stats(), check.Matches, `.*"UtimesOps":1,.*`)
 
        err = vol.Touch(loc)
        c.Check(err, check.IsNil)
        c.Check(stats(), check.Matches, `.*"FlockOps":1,.*`)
        c.Check(stats(), check.Matches, `.*"OpenOps":1,.*`)
-       c.Check(stats(), check.Matches, `.*"UtimesOps":1,.*`)
+       c.Check(stats(), check.Matches, `.*"UtimesOps":2,.*`)
 
        _, err = vol.Get(context.Background(), loc, make([]byte, 3))
        c.Check(err, check.IsNil)