This is a client library for PerfRepo written in Go.
The client has operations for manipulating with Tests, TestExecutions, Reports,
Report Permissions and more.
import "github.com/PerfCake/go-perfrepoclient/pkg/apis"
//create a Test object
perfRepoTest := &apis.Test{
Name: "Product XYZ Performance",
GroupID: "my_testing_group",
UID: "product_xyz_performance",
Description: "Holds performance numbers for product XYZ",
Metrics: []apis.Metric{
apis.Metric{
Comparator: "LB",
Name: "avg_requests_per_second",
Description: "Contains the average number of requests per second",
},
},
}
//call the API to actually send HTTP request to PerfRepo and create the Test
id, _ := testClient.CreateTest(perfRepoTest)
//print the id of the created test
fmt.Println("ID of the test:", id)
//retrieve the Test object by id
testBack, _ := testClient.GetTest(id)
//print the whole object including names of fields
fmt.Printf("Test object: %+v", testBack)
Create a TestExecution object:
//create a TestExecution object
testExec := &apis.TestExecution{
TestID: id, // the id that was returned by testClient.CreateTest() function
Name: "Distributed Mode",
Started: &apis.JaxbTime{time.Now()},
// add parameters metadata (detailed information about the test execution)
Parameters: []apis.TestExecutionParameter{
{
Name: "git_branch",
Value: "master",
},
{
Name: "git_commit",
Value: "88159a3b498760e0d637b0720401e593cc1f1d5d",
},
},
// add tags metadata (test executions will be searchable through them)
Tags: []apis.Tag{
{
Name: "distributed",
},
{
Name: "size4",
},
},
// add actual values
Values: []apis.Value{
{
MetricName: "avg_requests_per_second",
Result: 120.0,
},
},
}
//call the API to actually send HTTP request to PerfRepo and create the TestExecution
testExecID, err := testClient.CreateTestExecution(testExec)
if err != nil {
t.Fatal("Failed to create TestExecution", err.Error())
}
Run all E2E tests with PerfRepo running at default location (default
location is http://localhost:8080/testing-repo with username/password
perfrepouser/perfrepouser1.):
make test-e2e
Run all E2E tests with PerfRepo running at specific location
go test -tags=e2e -v -count=1 ./test/e2e --url http://perf.repo.url --user username --pass password