Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hive,libhive: add simulatorsVersion to hive and results JSONs #1033

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/hiveview/assets/lib/app-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function hiveInfoHTML(data) {
let link = makeLink(url, data.sourceCommit.substring(0, 8));
txt += '<span>commit: ' + link.outerHTML + '</span>';
}
if (data.simulatorsVersion) {
let url = 'https://github.com/ethereum/hive/commits/' + escape(data.simulatorsVersion);
let link = makeLink(url, data.simulatorsVersion.substring(0, 8));
txt += '<span>simulators: ' + link.outerHTML + '</span>';
}
return txt;
}

Expand Down
12 changes: 12 additions & 0 deletions hive.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"os"
"os/exec"
"os/signal"
"regexp"
"strings"
Expand Down Expand Up @@ -114,6 +115,7 @@ func main() {
SimRandomSeed: *simRandomSeed,
SimDurationLimit: *simTimeLimit,
ClientStartTimeout: *clientTimeout,
SimulatorsVersion: simulatorsVersion(),
}
runner := libhive.NewRunner(inv, builder, cb)

Expand Down Expand Up @@ -189,3 +191,13 @@ func flagIsSet(name string) bool {
})
return found
}

func simulatorsVersion() (commit *string) {
// Get the current folder's HEAD commit.
out, err := exec.Command("git", "rev-parse", "HEAD").Output()
if err != nil {
return nil
}
output := strings.TrimSpace(string(out[:]))
return &output
}
18 changes: 10 additions & 8 deletions internal/libhive/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ func (tsID TestID) String() string {

// TestSuite is a single run of a simulator, a collection of testcases.
type TestSuite struct {
ID TestSuiteID `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ClientVersions map[string]string `json:"clientVersions"`
TestCases map[TestID]*TestCase `json:"testCases"`
ID TestSuiteID `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ClientVersions map[string]string `json:"clientVersions"`
SimulatorsVersion *string `json:"simulatorsVersion,omitempty"`
TestCases map[TestID]*TestCase `json:"testCases"`

SimulatorLog string `json:"simLog"` // path to simulator log-file simulator. (may be shared with multiple suites)
TestDetailsLog string `json:"testDetailsLog"` // the test details output file
Expand Down Expand Up @@ -74,9 +75,10 @@ type ClientInfo struct {

// HiveInstance contains information about hive itself.
type HiveInstance struct {
SourceCommit string `json:"sourceCommit"`
SourceDate string `json:"sourceDate"`
BuildDate string `json:"buildDate"`
SourceCommit string `json:"sourceCommit"`
SourceDate string `json:"sourceDate"`
BuildDate string `json:"buildDate"`
SimulatorsVersion *string `json:"simulatorsVersion,omitempty"`
}

// ClientDefinition is served by the /clients API endpoint to list the available clients
Expand Down
5 changes: 3 additions & 2 deletions internal/libhive/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (r *Runner) Run(ctx context.Context, sim string, env SimEnv) (SimResult, er
if err := createWorkspace(env.LogDir); err != nil {
return SimResult{}, err
}
writeInstanceInfo(env.LogDir)
writeInstanceInfo(env.LogDir, env.SimulatorsVersion)
return r.run(ctx, sim, env)
}

Expand Down Expand Up @@ -303,9 +303,10 @@ func createWorkspace(logdir string) error {
return nil
}

func writeInstanceInfo(logdir string) {
func writeInstanceInfo(logdir string, simulatorsVersion *string) {
var obj HiveInstance
obj.SourceCommit, obj.SourceDate = hiveVersion()
obj.SimulatorsVersion = simulatorsVersion
buildDate := hiveBuildTime()
if !buildDate.IsZero() {
obj.BuildDate = buildDate.Format("2006-01-02T15:04:05Z")
Expand Down
20 changes: 12 additions & 8 deletions internal/libhive/testmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type SimEnv struct {
// This configures the amount of time the simulation waits
// for the client to open port 8545 after launching the container.
ClientStartTimeout time.Duration

// Information about the simulators to put in the results.
SimulatorsVersion *string
}

// SimResult summarizes the results of a simulation run.
Expand Down Expand Up @@ -395,14 +398,15 @@ func (manager *TestManager) StartTestSuite(name string, description string) (Tes
}

manager.runningTestSuites[newSuiteID] = &TestSuite{
ID: newSuiteID,
Name: name,
Description: description,
ClientVersions: make(map[string]string),
TestCases: make(map[TestID]*TestCase),
SimulatorLog: manager.simLogFile,
TestDetailsLog: testLogPath,
testDetailsFile: testLogFile,
ID: newSuiteID,
Name: name,
Description: description,
ClientVersions: make(map[string]string),
TestCases: make(map[TestID]*TestCase),
SimulatorLog: manager.simLogFile,
SimulatorsVersion: manager.config.SimulatorsVersion,
TestDetailsLog: testLogPath,
testDetailsFile: testLogFile,
}
manager.testSuiteCounter++
return newSuiteID, nil
Expand Down