Skip to content

Commit

Permalink
Merge branch 'konveyor:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
msajidmansoori12 committed May 3, 2024
2 parents 9e04ee3 + ea8c507 commit 39ea041
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 92 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ VENDOR_DIR ?= /tmp/konveyor-vendor
ARCH ?= amd64
JUNIT_REPORT_DIR ?= /tmp/junit-report

# Set MAVEN_TESTAPP_USER to the value of GITHUB_USER if GITHUB_USER is defined
MAVEN_TESTAPP_USER ?= $(GITHUB_USER)
MAVEN_TESTAPP_TOKEN ?= $(GITHUB_TOKEN)


# Setup local minikube with tackle - work in progress (TODO: enable auth)
# This is for local setup, CI uses shared github actions
Expand Down Expand Up @@ -44,7 +48,7 @@ test-tier2:

# TIER3
test-tier3:
TIER3=1 MAVEN_TESTAPP_USER=$(GITHUB_USER) MAVEN_TESTAPP_TOKEN=$(GITHUB_TOKEN) $(MAKE) test-analysis
TIER3=1 MAVEN_TESTAPP_USER='$(MAVEN_TESTAPP_USER)' MAVEN_TESTAPP_TOKEN='$(MAVEN_TESTAPP_TOKEN)' $(MAKE) test-analysis
$(MAKE) test-jira
$(MAKE) test-migrationwave

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ For parallel test execution, set `export PARALLEL=1`.
## Configuration

> **_NOTE:_** Before running tests, ensure that the required configuration variables are set as environment variables
<!-- TODO (mguetta1): add config file for example -->
You can edit the configuration file [go-konveyor-tests.config](go-konveyor-tests.config) and run:
```
source go-konveyor-tests.config
```

### Test-Specific Configuration

Expand Down
8 changes: 7 additions & 1 deletion analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ TIER1=1 make test-analysis

More advanced analysis parameters. Great if works.

Test cases: https://github.com/konveyor/go-konveyor-tests/blob/main/analysis/test_cases.go#L20
Test cases: https://github.com/konveyor/go-konveyor-tests/blob/main/analysis/test_cases.go#L19

```
TIER2=1 make test-analysis
```

### Tier 3

Application analysis with credentials, which are supplied as part of the test configuration. Should work.

Test cases: https://github.com/konveyor/go-konveyor-tests/blob/main/analysis/test_cases.go#L31

## Options

[HUB_BASE_URL](https://github.com/konveyor/tackle2-hub/tree/main/test#rest-api) is required in the same way as in API test.
Expand Down
39 changes: 27 additions & 12 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/cipher"
"crypto/sha256"
"encoding/hex"
"fmt"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -141,6 +142,11 @@ func TestApplicationAnalysis(t *testing.T) {
time.Sleep(Wait)
}

if task.State == "Running" {
t.Error("Timed out running the test. Details:")
pp.Println(task)
}

if task.State != "Succeeded" {
t.Error("Analyze Task failed. Details:")
pp.Println(task)
Expand Down Expand Up @@ -184,10 +190,13 @@ func TestApplicationAnalysis(t *testing.T) {
// Check the analysis issues
if len(gotAnalysis.Issues) != len(tc.Analysis.Issues) {
t.Errorf("Different amount of issues error. Got %d, expected %d.", len(gotAnalysis.Issues), len(tc.Analysis.Issues))
t.Error("Got:")
pp.Println(gotAnalysis.Issues)
t.Error("Expected:")
pp.Println(tc.Analysis.Issues)
missing, unexpected := getIssuesDiff(tc.Analysis.Issues, gotAnalysis.Issues)
for _, issue := range missing {
fmt.Printf("Expected issue not found for rule %s.\n", issue.Rule)
}
for _, issue := range unexpected {
fmt.Printf("Unexpected issue found for rule %s.\n", issue.Rule)
}
} else {
for i, got := range gotAnalysis.Issues {
expected := tc.Analysis.Issues[i]
Expand All @@ -202,10 +211,13 @@ func TestApplicationAnalysis(t *testing.T) {
}
if len(got.Incidents) != len(expected.Incidents) {
t.Errorf("Different amount of incidents error. Got %d, expected %d.", len(got.Incidents), len(expected.Incidents))
t.Error("Got:")
pp.Println(got.Incidents)
t.Error("Expected:")
pp.Println(expected.Incidents)
missing, unexpected := getIncidentsDiff(expected.Incidents, got.Incidents)
for _, incident := range missing {
fmt.Printf("Expected incident not found: %s line %d.\n", incident.File, incident.Line)
}
for _, incident := range unexpected {
fmt.Printf("Unexpected incident found: %s line %d.\n", incident.File, incident.Line)
}

} else {
// Ensure stable order of Incidents.
Expand Down Expand Up @@ -279,10 +291,13 @@ func TestApplicationAnalysis(t *testing.T) {
if len(tc.AnalysisTags) > 0 {
if len(tc.AnalysisTags) != len(gotApp.Tags) {
t.Errorf("Different Tags amount error. Got: %d, expected: %d.\n", len(gotApp.Tags), len(tc.AnalysisTags))
t.Error("Got:")
pp.Println(gotApp.Tags)
t.Error("Expected:")
pp.Println(tc.AnalysisTags)
notFoundTags, unexpectedTags := getTagsDiff(tc.AnalysisTags, gotTags)
for _, notFoundTag := range notFoundTags {
pp.Println("Expected tag not found", notFoundTag)
}
for _, unexpectedTag := range unexpectedTags {
pp.Println("Unexpected tag found\n", unexpectedTag)
}
} else {
for i, got := range gotTags {
expected := tc.AnalysisTags[i]
Expand Down
77 changes: 77 additions & 0 deletions analysis/compare.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package analysis

import (
"fmt"

"github.com/konveyor/tackle2-hub/api"
)

// Compare diffs for resources collections relevant for Analysis
func getTagsDiff(want, got []api.Tag) (notFound []api.Tag, extras []api.Tag) {
tagKey := func(t api.Tag) string { return fmt.Sprintf("%s-%s", t.Category.Name, t.Name) }
wantTags := map[string]api.Tag{}
gotTags := map[string]api.Tag{}
for _, gotTag := range got {
gotTags[tagKey(gotTag)] = gotTag
}
for _, wantTag := range want {
wantTags[tagKey(wantTag)] = wantTag
// find tags we expect, but not present in output
if _, found := gotTags[tagKey(wantTag)]; !found {
notFound = append(notFound, wantTag)
}
}
for _, gotTag := range got {
// find tags we got, but we didn't expect
if _, found := wantTags[tagKey(gotTag)]; !found {
extras = append(extras, gotTag)
}
}
return
}

func getIssuesDiff(wantList, gotList []api.Issue) (notFound []api.Issue, extras []api.Issue) {
key := func(r api.Issue) string { return fmt.Sprintf("%s-%s-%s-%d", r.Category, r.RuleSet, r.Rule, r.Effort) }
wantMap := map[string]api.Issue{}
gotMap := map[string]api.Issue{}
for _, got := range gotList {
gotMap[key(got)] = got
}
for _, want := range wantList {
wantMap[key(want)] = want
// find what we expect, but not present in output
if _, found := gotMap[key(want)]; !found {
notFound = append(notFound, want)
}
}
for _, got := range gotList {
// find what we got, but we didn't expect
if _, found := wantMap[key(got)]; !found {
extras = append(extras, got)
}
}
return
}

func getIncidentsDiff(wantList, gotList []api.Incident) (notFound []api.Incident, extras []api.Incident) {
key := func(r api.Incident) string { return fmt.Sprintf("%s-%d", r.File, r.Line) }
wantMap := map[string]api.Incident{}
gotMap := map[string]api.Incident{}
for _, got := range gotList {
gotMap[key(got)] = got
}
for _, want := range wantList {
wantMap[key(want)] = want
// find tags we expect, but not present in output
if _, found := gotMap[key(want)]; !found {
notFound = append(notFound, want)
}
}
for _, got := range gotList {
// find tags we got, but we didn't expect
if _, found := wantMap[key(got)]; !found {
extras = append(extras, got)
}
}
return
}
4 changes: 2 additions & 2 deletions analysis/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
RichClient *binding.RichClient

// Analysis waiting loop 5 minutes (60 * 5s)
Retry = 100
Retry = 200
Wait = 5 * time.Second
)

Expand Down Expand Up @@ -45,7 +45,7 @@ type TC struct {
Rules addon.Rules
Scope *addon.Scope
WithDeps bool
Binary bool
Binary bool
Artifact string
// After-analysis assertions.
ReportContent map[string][]string
Expand Down
46 changes: 22 additions & 24 deletions analysis/tc_tackle_testapp_private_binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var TackleTestappPrivateBinary = TC{
},
Binary: true,
Analysis: api.Analysis{
Effort: 16,
Effort: 15,
Issues: []api.Issue{
{
Category: "mandatory",
Expand All @@ -31,9 +31,9 @@ var TackleTestappPrivateBinary = TC{
Rule: "jni-native-code-00000",
Incidents: []api.Incident{
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/config/ApplicationConfiguration.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/config/ApplicationConfiguration.java",
Line: 17,
Message: "\n Java native libraries might not run in a cloud or container environment.",
Message: "Java native libraries might not run in a cloud or container environment.",
},
},
},
Expand All @@ -45,49 +45,44 @@ var TackleTestappPrivateBinary = TC{
Rule: "local-storage-00001",
Incidents: []api.Incident{
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/config/ApplicationConfiguration.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/config/ApplicationConfiguration.java",
Line: 8,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/config/ApplicationConfiguration.java",
Line: 37,
Message: "\n An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 39,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 40,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 41,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 42,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 61,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 62,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
{
File: "/addon/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/exception/handler/ExceptionHandlingController.java",
File: "/bin/maven/java-project/src/main/java/io/konveyor/demo/ordermanagement/exception/handler/ExceptionHandlingController.java",
Line: 20,
Message: "\n An application running inside a container could lose access to a file in local storage.",
Message: "An application running inside a container could lose access to a file in local storage.",
},
},
},
Expand All @@ -100,5 +95,8 @@ var TackleTestappPrivateBinary = TC{
{Name: "JNI", Category: api.Ref{Name: "Connect"}},
{Name: "Servlet", Category: api.Ref{Name: "Java EE"}},
{Name: "JNI", Category: api.Ref{Name: "Java EE"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Persistence"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Java EE"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Store"}},
},
}
5 changes: 4 additions & 1 deletion analysis/tc_tackle_testapp_public_deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var TackleTestappPublicWithDeps = TC{
{
File: "/cache/m2/io/konveyor/demo/configuration-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java",
Line: 14,
Message: "\n An application running inside a container could lose access to a file in local storage",
Message: "An application running inside a container could lose access to a file in local storage",
},
},
},
Expand Down Expand Up @@ -569,6 +569,7 @@ var TackleTestappPublicWithDeps = TC{
{Name: "Micrometer", Category: api.Ref{Name: "Integration"}},
{Name: "Spring DI", Category: api.Ref{Name: "Inversion of Control"}},
{Name: "Spring Data JPA", Category: api.Ref{Name: "Persistence"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Persistence"}},
{Name: "Properties", Category: api.Ref{Name: "Other"}},
{Name: "Spring Web", Category: api.Ref{Name: "Web"}},
{Name: "Spring DI", Category: api.Ref{Name: "Execute"}},
Expand All @@ -577,6 +578,7 @@ var TackleTestappPublicWithDeps = TC{
{Name: "Servlet", Category: api.Ref{Name: "Connect"}},
{Name: "Servlet", Category: api.Ref{Name: "Java EE"}},
{Name: "EJB XML", Category: api.Ref{Name: "Java EE"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Java EE"}},
{Name: "Properties", Category: api.Ref{Name: "Sustain"}},
{Name: "Properties", Category: api.Ref{Name: "Embedded"}},
{Name: "Spring Web", Category: api.Ref{Name: "Embedded"}},
Expand All @@ -585,5 +587,6 @@ var TackleTestappPublicWithDeps = TC{
{Name: "Micrometer", Category: api.Ref{Name: "Embedded"}},
{Name: "Spring Web", Category: api.Ref{Name: "View"}},
{Name: "Spring Data JPA", Category: api.Ref{Name: "Store"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Store"}},
},
}
3 changes: 3 additions & 0 deletions analysis/tc_tackle_testapp_public_package_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ var TackleTestappPublicPackageFilter = TC{
{Name: "Properties", Category: api.Ref{Name: "Other"}},
{Name: "EJB XML", Category: api.Ref{Name: "Java EE"}},
{Name: "Servlet", Category: api.Ref{Name: "Java EE"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Java EE"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Persistence"}},
{Name: "JPA named queries", Category: api.Ref{Name: "Store"}},
{Name: "Servlet", Category: api.Ref{Name: "Connect"}},
{Name: "Properties", Category: api.Ref{Name: "Sustain"}},
{Name: "EJB XML", Category: api.Ref{Name: "Connect"}},
Expand Down
8 changes: 4 additions & 4 deletions analysis/test_cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package analysis
var Tier0TestCases = []TC{
TackleTestappPublicWithDeps,
TackleTestappPublicPackageFilter,
AdministracionEfectivo,
}

// Tier 1 Analysis test cases - should work.
Expand All @@ -17,6 +16,7 @@ var Tier1TestCases = []TC{
// Tier 2 Analysis test cases - great if works.
// List of applications with expected analysis outputs.
var Tier2TestCases = []TC{
AdministracionEfectivo,
Tomcat,
TackleTestappPublic,
Daytrader,
Expand All @@ -25,8 +25,8 @@ var Tier2TestCases = []TC{
SeamBooking,
}

// Tier 3 Analysis test cases - should work
// Tier 3 Analysis with credentials test cases - should work
// List of applications with expected analysis outputs.
var Tier3TestCases = []TC {
TackleTestappPrivateBinary,
var Tier3TestCases = []TC{
TackleTestappPrivateBinary, // Needs GITHUB_USER and GITHUB_TOKEN env variables with Read access to https://github.com/konveyor/tackle-testapp
}
Loading

0 comments on commit 39ea041

Please sign in to comment.