Skip to content

Commit

Permalink
Merge pull request #6 from aufi/analysis-custom-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
aufi committed Jun 29, 2023
2 parents 770d2be + 6e41fd9 commit c0f2c33
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 462 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ $ make setup # start minikube&tackle using David's scripts - local env only
### Run test suite

```
$ make test
$ make test-all
```

Run test manually example:

```
$ export HUB_BASE_URL="http://`minikube ip`/hub"
$ go test -v analysis/windup_basic_test.go
$ go test -count=1 -v ./analysis/
```

For parallel analysis test execution, set ```export PARALLEL=1```.
Expand Down
11 changes: 11 additions & 0 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/konveyor/go-konveyor-tests/hack/addon"
"github.com/konveyor/go-konveyor-tests/hack/uniq"
"github.com/konveyor/go-konveyor-tests/hack/windupreport"
"github.com/konveyor/tackle2-hub/api"
"github.com/konveyor/tackle2-hub/test/assert"
)
Expand Down Expand Up @@ -85,6 +86,16 @@ func TestApplicationAnalysis(t *testing.T) {
}
}

// Check the analysis result (effort, issues, etc).
// Parse report for windup, get analysis from Hub API for lsp analyzer
gotAnalysis := windupreport.Parse(t, tc.Application.ID)
if gotAnalysis.Effort != tc.Analysis.Effort {
t.Errorf("Different effort error. Got %d, expected %d", gotAnalysis.Effort, tc.Analysis.Effort)
}
if !assert.FlatEqual(gotAnalysis.Issues, tc.Analysis.Issues) {
t.Errorf("Analysis Issues don't match. Got:\n %+v\nexpected:\n %+v\n", gotAnalysis.Issues, tc.Analysis.Issues)
}

// Check analysis-created Tags.
gotApp, _ := RichClient.Application.Get(tc.Application.ID)
found, gotAnalysisTags := 0, 0
Expand Down
1 change: 1 addition & 0 deletions analysis/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type TC struct {
TaskData string
// After-analysis assertions.
ReportContent map[string][]string
Analysis api.Analysis
AnalysisTags []api.Tag
}

Expand Down
167 changes: 150 additions & 17 deletions analysis/test_cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/konveyor/tackle2-hub/api"
)

//
// Test cases for Application Analysis.
var TestCases = []TC{
{
Expand All @@ -19,14 +18,43 @@ var TestCases = []TC{
Branch: "1.2.0",
},
},
Task: Windup,
Task: Analyze,
ReportContent: map[string][]string{
"/windup/report/index.html": {
"5\nstory points",
"5\nCloud Mandatory",
"9\nInformation",
},
},
Analysis: api.Analysis{
Effort: 5,
Issues: []api.Issue{
{
Category: "cloud-mandatory",
Description: "Trivial change or 1-1 library swap",
Effort: 5,
Name: "File system - Java IO",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Application properties file detected",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Bean Validation",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Maven POM (pom.xml)",
},
},
},
AnalysisTags: []api.Tag{
{Name: "CDI"},
{Name: "HTML"},
Expand All @@ -43,19 +71,54 @@ var TestCases = []TC{
Name: "Petclinic",
Description: "Spring framework app",
Repository: &api.Repository{
Kind: "git",
URL: "https://github.com/savitharaghunathan/spring-framework-petclinic.git",
Kind: "git",
URL: "https://github.com/savitharaghunathan/spring-framework-petclinic.git",
Branch: "main",
},
},
Task: Windup,
Task: Analyze,
ReportContent: map[string][]string{
"/windup/report/index.html": {
"5\nstory points",
"5\nCloud Mandatory",
"4\nInformation",
},
},
Analysis: api.Analysis{
Effort: 5,
Issues: []api.Issue{
{
Category: "cloud-mandatory",
Description: "Trivial change or 1-1 library swap",
Effort: 5,
Name: "File system - Java IO",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Embedded Spring Data JPA",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Embedded framework - Spring MVC",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Maven POM (pom.xml)",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Spring JMX configuration detected",
},
},
},
AnalysisTags: []api.Tag{
{Name: "Spring MVC"},
{Name: "CSS"},
Expand All @@ -72,14 +135,14 @@ var TestCases = []TC{
Name: "Petclinic",
Description: "Spring framework app",
Repository: &api.Repository{
Kind: "git",
URL: "https://github.com/savitharaghunathan/spring-framework-petclinic.git",
Kind: "git",
URL: "https://github.com/savitharaghunathan/spring-framework-petclinic.git",
Branch: "legacy",
},
},
CustomRules: []api.RuleSet{
{
Name: "Hazelcast Java distributed session store ruleset.",
Name: "Hazelcast Java distributed session store ruleset.",
Custom: true,
Image: api.Ref{
ID: 1,
Expand All @@ -93,14 +156,85 @@ var TestCases = []TC{
},
},
},
Task: Windup,
Task: Analyze,
ReportContent: map[string][]string{
"/windup/report/index.html": {
"12\nstory points",
"8\nCloud Mandatory",
"13\nInformation",
},
},
Analysis: api.Analysis{
Effort: 12,
Issues: []api.Issue{
{
Category: "cloud-mandatory",
Description: "Complex change with documented solution",
Effort: 6,
Name: "Embedded Hazelcast",
},
{
Category: "cloud-mandatory",
Description: "Trivial change or 1-1 library swap",
Effort: 1,
Name: "Embedded Hazelcast dependencies",
},
{
Category: "cloud-mandatory",
Description: "Trivial change or 1-1 library swap",
Effort: 5,
Name: "File system - Java IO",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Bean Validation",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Common Annotations",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Embedded Spring Data JPA",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Embedded framework - Spring MVC",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "JAXB",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Java Servlet",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Maven POM (pom.xml)",
},
{
Category: "information",
Description: "Info",
Effort: 0,
Name: "Spring JMX configuration detected",
},
},
},
AnalysisTags: []api.Tag{
{Name: "Java EE JAXB"},
{Name: "Servlet"},
Expand All @@ -116,25 +250,24 @@ var TestCases = []TC{
},
}

//
// Shared parameters.
var Addons = []string{
"windup", // legacy windup analyzer
// "analyzer", // LSP analyzer
"windup", // legacy windup analyzer
// "analyzer", // LSP analyzer
}

var Windup = api.Task{
State: "Ready", // Created / Ready
Data: defaultTaskData,
var Analyze = api.Task{
State: "Ready", // Created / Ready
Data: defaultTaskData,
}

var defaultTaskData = addon.Data{
Output: "/windup/report",
Mode: addon.Mode{
Artifact: "",
Binary: false,
Binary: false,
WithDeps: false,
Diva: true,
Diva: true,
},
Sources: []string{},
Targets: []string{"cloud-readiness"},
Expand Down
13 changes: 2 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ go 1.18

require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/gocolly/colly v1.2.0
github.com/konveyor/tackle2-hub v0.2.1-0.20230622161619-908a0a350015
github.com/konveyor/tackle2-addon v0.2.0
github.com/konveyor/tackle2-hub v0.2.1-0.20230627223342-1747a2022128
)

require (
github.com/Nerzal/gocloak/v10 v10.0.1 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/andygrunwald/go-jira v1.16.0 // indirect
github.com/antchfx/htmlquery v1.3.0 // indirect
github.com/antchfx/xmlquery v1.3.17 // indirect
github.com/antchfx/xpath v1.2.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.8.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand All @@ -35,11 +32,9 @@ require (
github.com/go-playground/validator/v10 v10.13.0 // indirect
github.com/go-resty/resty/v2 v2.6.0 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-querystring v1.1.0 // indirect
Expand All @@ -50,9 +45,7 @@ require (
github.com/jortel/go-utils v0.1.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/konveyor/tackle2-addon v0.2.0 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
Expand All @@ -68,10 +61,8 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/segmentio/ksuid v1.0.4 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
github.com/trivago/tgo v1.0.7 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
Expand Down
Loading

0 comments on commit c0f2c33

Please sign in to comment.