Skip to content

Commit

Permalink
Add Tackle testapp from Ramon
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Aufart <maufart@redhat.com>
  • Loading branch information
aufi committed Sep 15, 2023
1 parent b0615a3 commit 8f3bd68
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 15 deletions.
26 changes: 19 additions & 7 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func TestApplicationAnalysis(t *testing.T) {
if len(tc.Targets) > 0 {
taskData.Targets = tc.Targets
}
if len(tc.Labels.Included) > 0 || len(tc.Labels.Excluded) > 0 {
taskData.Rules.Labels = tc.Labels
}
if tc.Rules.Path != "" { // TODO: better rules handling
taskData.Rules = tc.Rules
}
Expand All @@ -93,11 +96,14 @@ func TestApplicationAnalysis(t *testing.T) {
t.Errorf("Analyze Task failed. Details: %+v", task)
}

var gotAppAnalyses []api.Analysis
var gotAnalysis api.Analysis

// Get LSP analysis directly form Hub API
analysisPath := binding.Path(api.AppAnalysisRoot).Inject(binding.Params{api.ID: tc.Application.ID})
assert.Should(t, Client.Get(analysisPath, &gotAnalysis))
analysisPath := binding.Path(api.AppAnalysesRoot).Inject(binding.Params{api.ID: tc.Application.ID})
assert.Should(t, Client.Get(analysisPath, &gotAppAnalyses))
analysisDetailPath := binding.Path(api.AnalysisRoot).Inject(binding.Params{api.ID: gotAppAnalyses[len(gotAppAnalyses)-1].ID})
assert.Should(t, Client.Get(analysisDetailPath, &gotAnalysis))

_, debug := os.LookupEnv("DEBUG")
if debug {
Expand Down Expand Up @@ -126,11 +132,12 @@ func TestApplicationAnalysis(t *testing.T) {
}
if len(got.Incidents) != len(expected.Incidents) {
t.Errorf("Different amount of incident error. Got %d, expected %d.", len(got.Incidents), len(expected.Incidents))
}
for j, gotInc := range got.Incidents {
expectedInc := expected.Incidents[j]
if gotInc.File != expectedInc.File || gotInc.Line != expectedInc.Line || !strings.HasPrefix(gotInc.Message, expectedInc.Message) {
t.Errorf("\nDifferent incident error. Got %+v, expected %+v.\n\n", gotInc, expectedInc)
} else {
for j, gotInc := range got.Incidents {
expectedInc := expected.Incidents[j]
if gotInc.File != expectedInc.File || gotInc.Line != expectedInc.Line || !strings.HasPrefix(gotInc.Message, expectedInc.Message) {
t.Errorf("\nDifferent incident error. Got %+v, expected %+v.\n\n", gotInc, expectedInc)
}
}
}
}
Expand All @@ -150,6 +157,11 @@ func TestApplicationAnalysis(t *testing.T) {
}
}

if debug {
DumpTags(t, tc, *gotApp)
}


// TODO(maufart): analysis tagger creates duplicate tags, not sure if it is expected, check later.
//if len(tc.AnalysisTags) != len(gotApp.Tags) {
// t.Errorf("Different Tags amount error. Got: %d, expected: %d.\n", len(gotApp.Tags), len(tc.AnalysisTags))
Expand Down
9 changes: 3 additions & 6 deletions analysis/analyzer_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var defaultAnalyzerData = addon.Data{
Artifact: "",
Binary: false,
WithDeps: false,
//Diva: true,
// Diva: true,
},
Sources: []string{},
Targets: []string{},
Expand All @@ -30,13 +30,10 @@ var defaultAnalyzerData = addon.Data{
},
Rules: addon.Rules{
Path: "",
Labels: struct {
Included []string `json:"included,omitempty"`
Excluded []string `json:"excluded,omitempty"`
}{
Labels: addon.Labels{
Excluded: []string{},
Included: []string{
"cloud-readiness",
"cloud-readiness",
},
},
//Tags: {
Expand Down
1 change: 1 addition & 0 deletions analysis/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type TC struct {
TaskData string
Sources []string
Targets []string
Labels addon.Labels
Rules addon.Rules
// After-analysis assertions.
ReportContent map[string][]string
Expand Down
109 changes: 109 additions & 0 deletions analysis/tc_tackle_testapp_public.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package analysis

import (
"github.com/konveyor/go-konveyor-tests/hack/addon"
"github.com/konveyor/tackle2-hub/api"
)

var TackleTestappPublic = TC{
Name: "Tackle Testapp public",
Application: api.Application{
Name: "Tackle Testapp public",
Repository: &api.Repository{
Kind: "git",
URL: "https://github.com/konveyor/tackle-testapp-public",
},
},
Task: Analyze,
Labels: addon.Labels{
Included: []string{
"konveyor.io/target=linux",
"konveyor.io/target=cloud-readiness",
},
},
Analysis: api.Analysis{
Effort: 10,
Issues: []api.Issue{
{
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",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/target/classes/persistence.properties",
Line: 0,
Message: "When migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/resources/persistence.properties",
Line: 0,
Message: "When migrating environments, hard-coded IP addresses may need to be modified or eliminated.",
},
},
},
{
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",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 0,
Message: "An 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.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 0,
Message: "An 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.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 0,
Message: "An 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.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 0,
Message: "An 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.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 0,
Message: "An 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.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 0,
Message: "An 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.",
},
{
File: "/addon/source/tackle-testapp-public/src/main/java/io/konveyor/demo/ordermanagement/config/PersistenceConfig.java",
Line: 0,
Message: "An 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.",
},
},
},
{
Category: "mandatory",
Description: "Windows file system path\nThis file system path is Microsoft Windows platform dependent. It needs to be replaced with a Linux-style path.",
Effort: 1,
RuleSet: "os/windows",
Rule: "os-specific-00001",
Incidents: []api.Incident{
{
File: "/addon/source/tackle-testapp-public/.git/hooks/fsmonitor-watchman.sample",
Line: 0,
Message: "This file system path is Microsoft Windows platform dependent. It needs to be replaced with a Linux-style path.",
},
},
},
},
},
// Tags are empty right now.
AnalysisTags: []api.Tag{
},
}
1 change: 1 addition & 0 deletions analysis/tc_tomcat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var Tomcat = TC{
Task: Analyze,
Targets: []string{
"cloud-readiness",
"linux",
},
Analysis: api.Analysis{
Effort: 1,
Expand Down
3 changes: 1 addition & 2 deletions analysis/test_cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ package analysis
// Tier 0 Analysis test cases - should never fail.
// List of applications with expected analysis outputs.
var Tier0TestCases = []TC{
Tomcat,
PathfinderSample,
TackleTestappPublic,
}

//
Expand Down
3 changes: 3 additions & 0 deletions hack/analysis-windup/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func TestApplicationAnalysis(t *testing.T) {
if len(tc.Targets) > 0 {
taskData.Targets = tc.Targets
}
//if len(tc.Labels.Included) > 0 || len(tc.Labels.Excluded) > 0 {
// taskData.Rules.Labels = tc.Labels
//}
//if tc.Rules.Path != "" { // TODO: better rules handling
// taskData.Rules = tc.Rules
//}
Expand Down
1 change: 1 addition & 0 deletions hack/analysis-windup/analyzer_legacy_windup.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var defaultWindupData = addonwindup.Data{
Path: "",
Labels: []string{
"cloud-readiness",
"linux",
},
//Tags: {
// Excluded: []string{},
Expand Down

0 comments on commit 8f3bd68

Please sign in to comment.