Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
Update parsing logic and increment application version
Browse files Browse the repository at this point in the history
The parsing logic in parser.go has been updated to compare directory modification time with application start time, replacing the previous method of parsing a date-time from the directory name. Furthermore, the application version in root.go was incremented to v1.0.2.
  • Loading branch information
PeterPaul-Perfana committed Jan 27, 2024
1 parent c0f2002 commit fb2864b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Next will search for simulation.log file to appear and start processing it.`,
Long: `This application allows writing raw Gatling load testing
tool logs directly to InfluxDB avoiding unnecessary
complications of Graphite protocol.`,
Version: "v0.1.0",
Version: "v1.0.2",
PreRunE: preRunSetup,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
18 changes: 10 additions & 8 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,14 @@ func lookupTargetDir(ctx context.Context, dir string) error {
}

func walkFunc(path string, info os.FileInfo, err error) error {

if info.IsDir() && resultDirNamePattern.MatchString(info.Name()) {
dateString := resultDirNamePattern.FindStringSubmatch(info.Name())[1]
t, _ := time.Parse("20060102150405", dateString)
if t.Unix() > startTime {
// l.Debugf("Found directory '%s' with mod time %s", path, info.ModTime().String())
if info.ModTime().Unix() > startTime {
logDir = path
l.Infof("Found log directory at %s", logDir)

l.Infof("Log directory '%s' with mod time %s is newer than startTime %s", logDir,
info.ModTime().String(),
time.Unix(startTime, 0).String())
return errFound
}
}
Expand All @@ -137,9 +138,10 @@ func walkFunc(path string, info os.FileInfo, err error) error {

// logic is the following: at the start of the application current timestamp is saved
// then traversing over all directories inside target dir is initiated.
// Every dir name is matched against pattern, if found - date time from dir name
// is parsed and result timestamp is matched against application start time.
// Function stops as soon as matched date time is higher then initial one
// Every dir name is matched against pattern, if found - modification time of directory is
// compared with application start time.
//
// This function stops as soon as directory modification time is after start time.
func lookupResultsDir(ctx context.Context, dir string) error {
const loopTimeout = 5 * time.Second

Expand Down

0 comments on commit fb2864b

Please sign in to comment.