Skip to content

Commit

Permalink
Merge pull request #43 from aufi/separate-analysis-deps
Browse files Browse the repository at this point in the history
Separate analysis deps
  • Loading branch information
aufi committed Oct 10, 2023
2 parents ebecd40 + af0c5de commit 5e40e10
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 122 deletions.
54 changes: 33 additions & 21 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,21 @@ func TestApplicationAnalysis(t *testing.T) {
sort.SliceStable(gotAnalysis.Dependencies, func(a, b int) bool { return gotAnalysis.Dependencies[a].Name < gotAnalysis.Dependencies[b].Name })
sort.SliceStable(tc.Analysis.Dependencies, func(a, b int) bool { return tc.Analysis.Dependencies[a].Name < tc.Analysis.Dependencies[b].Name })

// Check the dependencies.
if len(gotAnalysis.Dependencies) != len(tc.Analysis.Dependencies) {
t.Errorf("Different amount of dependencies error. Got %d, expected %d.", len(gotAnalysis.Dependencies), len(tc.Analysis.Dependencies))
t.Errorf("Got: %+v\nExpected: %+v.\n", gotAnalysis.Dependencies, tc.Analysis.Dependencies)
} else {
for i, got := range gotAnalysis.Dependencies {
expected := tc.Analysis.Dependencies[i]
if got.Name != expected.Name || got.Version != expected.Version || got.Provider != expected.Provider {
t.Errorf("\nDifferent dependency error. Got %+v\nExpected %+v.\n\n", got, expected)
// Check the dependencies (if specified by TestCase).
if len(tc.Analysis.Dependencies) > 0 {
if len(gotAnalysis.Dependencies) != len(tc.Analysis.Dependencies) {
t.Errorf("Different amount of dependencies error. Got %d, expected %d.", len(gotAnalysis.Dependencies), len(tc.Analysis.Dependencies))
t.Errorf("Got: %+v\nExpected: %+v.\n", gotAnalysis.Dependencies, tc.Analysis.Dependencies)
} else {
for i, got := range gotAnalysis.Dependencies {
expected := tc.Analysis.Dependencies[i]
if got.Name != expected.Name || got.Version != expected.Version || got.Provider != expected.Provider {
t.Errorf("\nDifferent dependency error. Got %+v\nExpected %+v.\n\n", got, expected)
}
}
}
} else {
t.Log("Skipping Dependencies check, nothing is expected.")
}

// Check analysis-created Tags.
Expand All @@ -193,20 +197,28 @@ func TestApplicationAnalysis(t *testing.T) {
}

// Ensure stable order of Tags.
sort.SliceStable(gotTags, func(a, b int) bool { return gotTags[a].Name + gotTags[a].Category.Name < gotTags[b].Name + gotTags[b].Category.Name })
sort.SliceStable(tc.AnalysisTags, func(a, b int) bool { return tc.AnalysisTags[a].Name + tc.AnalysisTags[a].Category.Name < tc.AnalysisTags[b].Name + tc.AnalysisTags[b].Category.Name })

// Check Tags.
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.Errorf("Got: %+v\nExpected: %+v.\n", gotApp.Tags, tc.AnalysisTags)
} else {
for i, got := range gotTags {
expected := tc.AnalysisTags[i]
if got.Name != expected.Name || got.Category.Name != expected.Category.Name {
t.Errorf("\nDifferent tag error. Got %+v\nExpected %+v.\n\n", got, expected)
sort.SliceStable(gotTags, func(a, b int) bool {
return gotTags[a].Name+gotTags[a].Category.Name < gotTags[b].Name+gotTags[b].Category.Name
})
sort.SliceStable(tc.AnalysisTags, func(a, b int) bool {
return tc.AnalysisTags[a].Name+tc.AnalysisTags[a].Category.Name < tc.AnalysisTags[b].Name+tc.AnalysisTags[b].Category.Name
})

// Check Tags (if specified by TestCase).
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.Errorf("Got: %+v\nExpected: %+v.\n", gotApp.Tags, tc.AnalysisTags)
} else {
for i, got := range gotTags {
expected := tc.AnalysisTags[i]
if got.Name != expected.Name || got.Category.Name != expected.Category.Name {
t.Errorf("\nDifferent tag error. Got %+v\nExpected %+v.\n\n", got, expected)
}
}
}
} else {
t.Log("Skipping Tags check, nothing is expected.")
}

// Allow skip cleanup to keep applications and analysis results for debugging etc.
Expand Down
110 changes: 9 additions & 101 deletions analysis/tc_tackle_testapp_public.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var TackleTestappPublic = TC{
Name: "Tackle Testapp public",
Application: TackleTestApp,
Task: Analyze,
WithDeps: true,
WithDeps: false,
Labels: addon.Labels{
Included: []string{
"konveyor.io/target=linux",
Expand All @@ -28,11 +28,11 @@ var TackleTestappPublic = TC{
Effort: 9,
Issues: []api.Issue{
{
Category: "mandatory",
Category: "mandatory",
Description: "Hardcoded IP Address\nWhen migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
Effort: 1,
RuleSet: "discovery-rules",
Rule: "hardcoded-ip-address",
Effort: 1,
RuleSet: "discovery-rules",
Rule: "hardcoded-ip-address",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/target/classes/persistence.properties",
Expand All @@ -47,11 +47,11 @@ var TackleTestappPublic = TC{
},
},
{
Category: "mandatory",
Category: "mandatory",
Description: "File system - Java IO\nAn application running inside a container could lose access to a file in local storage.. Recommendations. The following recommendations depend on the function of the file in local storage:. * Logging: Log to standard output and use a centralized log collector to analyze the logs.. * Caching: Use a cache backing service.. * Configuration: Store configuration settings in environment variables so that they can be updated without code changes.. * Data storage: Use a database backing service for relational data or use a persistent data storage system.. * Temporary data storage: Use the file system of a running container as a brief, single-transaction cache.",
Effort: 1,
RuleSet: "openshift",
Rule: "local-storage-00001",
Effort: 1,
RuleSet: "openshift",
Rule: "local-storage-00001",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Expand Down Expand Up @@ -91,98 +91,6 @@ var TackleTestappPublic = TC{
},
},
},
Dependencies: []api.TechDependency{
{
Name: "com.fasterxml.jackson.jackson-bom",
Version: "${jackson.version}",
Provider: "",
},
{
Name: "org.springframework.data.spring-data-bom",
Version: "${spring-data.version}",
Provider: "",
},
{
Name: "org.apache.tomcat.tomcat-servlet-api",
Version: "${tomcat.version}",
Provider: "",
},
{
Name: "com.fasterxml.jackson.core.jackson-core",
Version: "",
Provider: "",
},
{
Name: "com.fasterxml.jackson.core.jackson-databind",
Version: "",
Provider: "",
},
{
Name: "org.springframework.data.spring-data-jpa",
Version: "",
Provider: "",
},
{
Name: "org.springframework.spring-jdbc",
Version: "${spring-framework.version}",
Provider: "",
},
{
Name: "org.springframework.spring-webmvc",
Version: "${spring-framework.version}",
Provider: "",
},
{
Name: "org.springframework.spring-web",
Version: "${spring-framework.version}",
Provider: "",
},
{
Name: "org.springframework.boot.spring-boot-starter-actuator",
Version: "2.5.0",
Provider: "",
},
{
Name: "org.apache.tomcat.tomcat-jdbc",
Version: "${tomcat.version}",
Provider: "",
},
{
Name: "org.hibernate.hibernate-entitymanager",
Version: "${hibernate.version}",
Provider: "",
},
{
Name: "org.hibernate.validator.hibernate-validator",
Version: "${hibernate-validator.version}",
Provider: "",
},
{
Name: "ch.qos.logback.logback-classic",
Version: "1.1.7",
Provider: "",
},
{
Name: "com.oracle.database.jdbc.ojdbc11",
Version: "21.1.0.0",
Provider: "",
},
{
Name: "org.postgresql.postgresql",
Version: "42.2.23",
Provider: "",
},
{
Name: "com.h2database.h2",
Version: "2.1.214",
Provider: "",
},
{
Name: "io.konveyor.demo.configuration-utils",
Version: "1.0.0",
Provider: "",
},
},
},
AnalysisTags: []api.Tag{
{Name: "EJB XML", Category: api.Ref{Name: "Bean"}},
Expand Down
Loading

0 comments on commit 5e40e10

Please sign in to comment.