Skip to content

Commit

Permalink
corrected log lines for gherkin tests
Browse files Browse the repository at this point in the history
Signed-off-by: Savvas Kyriacou <[email protected]>
  • Loading branch information
KirbyKatcher committed Feb 22, 2024
1 parent 6c211b2 commit 5c62937
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 62 deletions.
1 change: 0 additions & 1 deletion pkg/cmd/runsSubmitLocal.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func (cmd *RunsSubmitLocalCommand) createRunsSubmitLocalCobraCmd(
"The maven coordinates of the obr bundle(s) which refer to your test bundles. "+
"The format of this parameter is 'mvn:${TEST_OBR_GROUP_ID}/${TEST_OBR_ARTIFACT_ID}/${TEST_OBR_VERSION}/obr' "+
"Multiple instances of this flag can be used to describe multiple obr bundles.")
//runsSubmitLocalCobraCmd.MarkFlagRequired("obr")

runsSubmitLocalCobraCmd.Flags().Uint32Var(&cmd.values.runsSubmitLocalCmdParams.DebugPort, "debugPort", 0,
"The port to use when the --debug option causes the testcase to connect to a java debugger. "+
Expand Down
28 changes: 14 additions & 14 deletions pkg/launcher/jvmLauncher.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ type RunsSubmitLocalCmdParameters struct {
// A list of OBRs, which we hope one of these contains the tests we want to run.
Obrs []string


// The local maven repo, eg: file:///home/.m2/repository, where we can load the galasa uber-obr
LocalMaven string

Expand Down Expand Up @@ -151,7 +150,6 @@ func NewJVMLauncher(
launcher.embeddedFileSystem,
)
}


return launcher, err
}
Expand Down Expand Up @@ -182,14 +180,18 @@ func (launcher *JvmLauncher) SubmitTestRun(
obrFromPortfolio string,
isTraceEnabled bool,
gherkinURL string,
GherkinFeature string,
overrides map[string]interface{},
) (*galasaapi.TestRuns, error) {

log.Printf("JvmLauncher: SubmitTestRun entered. group=%s className=%s "+
"requestType=%s requestor=%s stream=%s isTraceEnabled=%v",
groupName, className, requestType,
requestor, stream, isTraceEnabled)
log.Printf("Submit Run - GherkunURL >"+ gherkinURL)
if gherkinURL != "" {
log.Printf("JvmLauncher: SubmitTestRun entered. gherkinUrl=%s", GherkinFeature)
} else {
log.Printf("JvmLauncher: SubmitTestRun entered. group=%s className=%s "+
"requestType=%s requestor=%s stream=%s isTraceEnabled=%v",
groupName, className, requestType,
requestor, stream, isTraceEnabled)
}
var err error
testRuns := new(galasaapi.TestRuns)

Expand All @@ -198,7 +200,7 @@ func (launcher *JvmLauncher) SubmitTestRun(
obrs, err = buildListOfAllObrs(launcher.cmdParams.Obrs, obrFromPortfolio)
if err == nil {

if len(obrs) < 1 {
if len(obrs) < 1 && gherkinURL == "" {
// There are no obrs ! We have no idea how to find the test!
err = galasaErrors.NewGalasaError(galasaErrors.GALASA_ERROR_NO_OBR_SPECIFIED_ON_INPUTS, className)
}
Expand All @@ -221,10 +223,10 @@ func (launcher *JvmLauncher) SubmitTestRun(
testRuns.Runs = make([]galasaapi.TestRun, 0)

var testClassToLaunch *TestLocation
if className != ""{
if className != "" {
testClassToLaunch, err = classNameUserInputToTestClassLocation(className)
} else {
//Set to empty for the command
//Set to empty for the command as this is a Gherkin Test
testClassToLaunch = &TestLocation{
OSGiBundleName: "",
QualifiedJavaClassName: "",
Expand Down Expand Up @@ -258,7 +260,7 @@ func (launcher *JvmLauncher) SubmitTestRun(
launcher.localTests = append(launcher.localTests, localTest)

localTest.testRun = new(galasaapi.TestRun)
if testClassToLaunch.OSGiBundleName !=""{
if testClassToLaunch.OSGiBundleName != "" {
localTest.testRun.SetBundleName(testClassToLaunch.OSGiBundleName)
}
localTest.testRun.SetStream(stream)
Expand Down Expand Up @@ -541,8 +543,6 @@ func getCommandSyntax(

args = append(args, "-Dfile.encoding=UTF-8")



nativeGalasaHomeFolderPath := galasaHome.GetNativeFolderPath()
args = append(args, `-DGALASA_HOME="`+nativeGalasaHomeFolderPath+`"`)

Expand Down Expand Up @@ -591,7 +591,7 @@ func getCommandSyntax(
args = append(args, "--test")
args = append(args, testLocation.OSGiBundleName+"/"+testLocation.QualifiedJavaClassName)
}

if isTraceEnabled {
args = append(args, "--trace")
}
Expand Down
11 changes: 8 additions & 3 deletions pkg/launcher/jvmLauncher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func TestCanLaunchLocalJvmTest(t *testing.T) {
"mvn:myGroup/myArtifact/myClassifier/obr",
isTraceEnabled,
"", // No Gherkin URL supplied
"", // No Gherkin Feature supplied
overrides,
)
if err != nil {
Expand Down Expand Up @@ -216,6 +217,7 @@ func TestCanGetRunGroupStatus(t *testing.T) {
"mvn:myGroup/myArtifact/myClassifier/obr",
isTraceEnabled,
"", // No Gherkin URL supplied
"", // No Gherkin Feature supplied
overrides,
)

Expand Down Expand Up @@ -354,6 +356,7 @@ func TestBadlyFormedObrFromProfileInfoCausesError(t *testing.T) {
"notmaven://group/artifact/version/classifier",
isTraceEnabled,
"", // No Gherkin URL supplied
"", // No Gherkin Feature supplied
overrides,
)

Expand Down Expand Up @@ -391,6 +394,7 @@ func TestNoObrsFromParameterOrProfileCausesError(t *testing.T) {
"", // No Obr from the profile record.
isTraceEnabled,
"", // No Gherkin URL supplied
"", // No Gherkin Feature supplied
overrides,
)

Expand Down Expand Up @@ -1194,12 +1198,13 @@ func TestCanLaunchLocalJvmGherkinTest(t *testing.T) {
testRuns, err := launcher.SubmitTestRun(
"myGroup",
"", // No Java Class as this is a gherkin test
"myRequestType-UnitTest",
"", // No RequestType as this is a gherkin test
"myRequestor",
"unitTestStream",
"mvn:myGroup/myArtifact/myClassifier/obr",
"", // No Stream as this is a gherkin test
"", // No OBR as this is a gherkin test
isTraceEnabled,
"file:///dev.galasa.simbank.tests/src/main/java/dev/galasa/simbank/tests/GherkinLog.feature",
"GherkinLog",
overrides,
)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Launcher interface {
obrFromPortfolio string,
isTraceEnabled bool,
gherkinURL string,
GherkinFeature string,
overrides map[string]interface{},
) (*galasaapi.TestRuns, error)

Expand Down
2 changes: 2 additions & 0 deletions pkg/launcher/launcherMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type LaunchParameters struct {
ObrFromPortfolio string
IsTraceEnabled bool
GherkinURL string
GherkinFeature string
Overrides map[string]interface{}
}

Expand Down Expand Up @@ -71,6 +72,7 @@ func (launcher *MockLauncher) SubmitTestRun(
obrFromPortfolio string,
isTraceEnabled bool,
GherkinURL string,
GherkinFeature string,
overrides map[string]interface{},
) (*galasaapi.TestRuns, error) {

Expand Down
1 change: 1 addition & 0 deletions pkg/launcher/remoteLauncher.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (launcher *RemoteLauncher) SubmitTestRun(
obrFromPortfolio string,
isTraceEnabled bool,
GherkinURL string,
GherkinFeature string,
overrides map[string]interface{},
) (*galasaapi.TestRuns, error) {

Expand Down
6 changes: 4 additions & 2 deletions pkg/runs/jsonReporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestJsonReportWorks(t *testing.T) {
Result: "PASSED",
Overrides: make(map[string]string, 1),
Tests: []TestMethod{{Method: "method1", Result: "passed"}, {Method: "method2", Result: "passed"}},
GherkinUrl: "myfeature",
GherkinUrl: "file:///my.feature",
GherkinFeature: "my",
}

finishedRunsMap := make(map[string]*TestRun, 1)
Expand Down Expand Up @@ -76,7 +77,8 @@ func TestJsonReportWorks(t *testing.T) {
"result": "passed"
}
],
"GherkinUrl":"myfeature"
"GherkinUrl":"file:///my.feature",
"GherkinFeature":"my"
}
]
}`
Expand Down
25 changes: 13 additions & 12 deletions pkg/runs/runTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
package runs

type TestRun struct {
Name string `yaml:"name" json:"name"`
Bundle string `yaml:"bundle" json:"bundle"`
Class string `yaml:"class" json:"class"`
Stream string `yaml:"stream" json:"stream"`
Obr string `yaml:"obr" json:"obr"`
Status string `yaml:"status" json:"status"`
QueuedTimeUTC string `yaml:"queued" json:"queued"`
Requestor string `yaml:"requestor" json:"requestor"`
Result string `yaml:"result" json:"result"`
Overrides map[string]string `yaml:"overrides" json:"overrides"`
Tests []TestMethod `yaml:"tests" json:"tests"`
GherkinUrl string `yaml:"gherkin"`
Name string `yaml:"name" json:"name"`
Bundle string `yaml:"bundle" json:"bundle"`
Class string `yaml:"class" json:"class"`
Stream string `yaml:"stream" json:"stream"`
Obr string `yaml:"obr" json:"obr"`
Status string `yaml:"status" json:"status"`
QueuedTimeUTC string `yaml:"queued" json:"queued"`
Requestor string `yaml:"requestor" json:"requestor"`
Result string `yaml:"result" json:"result"`
Overrides map[string]string `yaml:"overrides" json:"overrides"`
Tests []TestMethod `yaml:"tests" json:"tests"`
GherkinUrl string `yaml:"gherkin"`
GherkinFeature string `yaml:"feature"`
}

type TestMethod struct {
Expand Down
51 changes: 36 additions & 15 deletions pkg/runs/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,11 @@ func (submitter *Submitter) submitRun(
var resultGroup *galasaapi.TestRuns
log.Printf("Submit Run - GherkunURL >" + nextRun.GherkinUrl)
resultGroup, err = submitter.launcher.SubmitTestRun(groupName, className, requestType, requestor,
nextRun.Stream, nextRun.Obr, trace, nextRun.GherkinUrl, submitOverrides)
nextRun.Stream, nextRun.Obr, trace, nextRun.GherkinUrl, nextRun.GherkinFeature, submitOverrides)
if err != nil {
log.Printf("Failed to submit test %v/%v - %v\n", nextRun.Bundle, nextRun.Class, err)
lostRuns[className] = &nextRun
//This is thrown when test submit is run.... Unit test and fix
err = galasaErrors.NewGalasaError(galasaErrors.GALASA_ERROR_FAILED_TO_SUBMIT_TEST, nextRun.Bundle, nextRun.Class, err.Error())
} else {
if len(resultGroup.GetRuns()) < 1 {
Expand All @@ -325,7 +326,11 @@ func (submitter *Submitter) submitRun(

submittedRuns[nextRun.Name] = &nextRun

log.Printf("Run %v submitted - %v/%v/%v\n", nextRun.Name, nextRun.Stream, nextRun.Bundle, nextRun.Class)
if nextRun.GherkinUrl != "" {
log.Printf("Run %v submitted - %v\n", nextRun.Name, nextRun.GherkinFeature)
} else {
log.Printf("Run %v submitted - %v/%v/%v\n", nextRun.Name, nextRun.Stream, nextRun.Bundle, nextRun.Class)
}
}
}
}
Expand Down Expand Up @@ -392,13 +397,20 @@ func (submitter *Submitter) runsFetchCurrentStatus(
}
}
}

log.Printf("Run %v has finished(%v) - %v/%v/%v\n", runName, result, checkRun.Stream, checkRun.Bundle, checkRun.Class)
if checkRun.GherkinUrl != "" {
log.Printf("Run %v has finished(%v) - %v\n", runName, result, checkRun.GherkinFeature)
} else {
log.Printf("Run %v has finished(%v) - %v/%v/%v\n", runName, result, checkRun.Stream, checkRun.Bundle, checkRun.Class)
}
} else {
// Check to see if there was a status change
if checkRun.Status != currentRun.GetStatus() {
checkRun.Status = currentRun.GetStatus()
log.Printf(" Run %v status is now '%v' - %v/%v/%v\n", runName, checkRun.Status, checkRun.Stream, checkRun.Bundle, checkRun.Class)
if checkRun.GherkinUrl != "" {
log.Printf(" Run %v status is now '%v' - %v\n", runName, checkRun.Status, checkRun.GherkinFeature)
} else {
log.Printf(" Run %v status is now '%v' - %v/%v/%v\n", runName, checkRun.Status, checkRun.Stream, checkRun.Bundle, checkRun.Class)
}
}
}
}
Expand Down Expand Up @@ -472,16 +484,25 @@ func (submitter *Submitter) buildListOfRunsToSubmit(portfolio *Portfolio, runOve
readyRuns := make([]TestRun, 0, len(portfolio.Classes))
currentUser := submitter.GetCurrentUserName()
for _, portfolioTest := range portfolio.Classes {
var featureName = ""
if portfolioTest.GherkinUrl != "" {
// split the Gherkin URL and select the last element from the array which should be the feature file name
featureSlice := strings.Split(portfolioTest.GherkinUrl, "/")
featureName = featureSlice[len(featureSlice)-1]
// remove the .feature extension from the url
featureName = strings.TrimSuffix(featureName, ".feature")
}
newTestrun := TestRun{
Bundle: portfolioTest.Bundle,
Class: portfolioTest.Class,
Stream: portfolioTest.Stream,
Obr: portfolioTest.Obr,
QueuedTimeUTC: submitter.timeService.Now().String(),
Requestor: currentUser,
Status: "queued",
Overrides: make(map[string]string, 0),
GherkinUrl: portfolioTest.GherkinUrl,
Bundle: portfolioTest.Bundle,
Class: portfolioTest.Class,
Stream: portfolioTest.Stream,
Obr: portfolioTest.Obr,
QueuedTimeUTC: submitter.timeService.Now().String(),
Requestor: currentUser,
Status: "queued",
Overrides: make(map[string]string, 0),
GherkinUrl: portfolioTest.GherkinUrl,
GherkinFeature: featureName,
}

// load the run overrides
Expand All @@ -498,7 +519,7 @@ func (submitter *Submitter) buildListOfRunsToSubmit(portfolio *Portfolio, runOve
if newTestrun.GherkinUrl == "" {
log.Printf("Added test %v/%v/%v to the ready queue\n", newTestrun.Stream, newTestrun.Bundle, newTestrun.Class)
} else {
log.Printf("Added gherkin test %v to the ready queue\n", newTestrun.GherkinUrl)
log.Printf("Added gherkin test %v to the ready queue\n", newTestrun.GherkinFeature)
}
}

Expand Down
Loading

0 comments on commit 5c62937

Please sign in to comment.