Skip to content

Commit

Permalink
Merge pull request #29 from mguetta1/todos
Browse files Browse the repository at this point in the history
Errors handling
  • Loading branch information
mguetta1 committed Sep 18, 2023
2 parents 77a7ecb + b562de8 commit 790e00a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
2 changes: 0 additions & 2 deletions analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Due to fragile nature of some analysis parameters for more complex applications,

Very basic Application->Task->Analyze->Result flow. Should never fail.

TestCases from this stage are automaticaly included in analysis test executions.

### Stage 1

Common example application analysis. Should work.
Expand Down
3 changes: 1 addition & 2 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// Test application analysis
func TestApplicationAnalysis(t *testing.T) {
// Find right test cases for given Tier (include Tier0 always).
// Find right test cases for given Tier.
testCases := Tier0TestCases
_, tier1 := os.LookupEnv("TIER1")
if tier1 {
Expand Down Expand Up @@ -170,7 +170,6 @@ func TestApplicationAnalysis(t *testing.T) {
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
3 changes: 2 additions & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"RETRY_NUM": "10"
"RETRY_NUM": "10",
"KEEP": "0"
}
1 change: 1 addition & 0 deletions config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ type Configuration struct {
JIRA_PASSWORD string `env:"JIRA_PASSWORD"`
JIRA_URL string `env:"JIRA_URL"`
RETRY_NUM string `env:"RETRY_NUM"`
KEEP string `env:"KEEP"`
}
10 changes: 6 additions & 4 deletions e2e/jiraintegration/jira_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ const (

var _ = Describe("Jira Connection", Ordered, func() {
AfterAll(func() {
// Resources cleanup
// Delete tracker instance and the associated identity after

//TODO - error handling
Tracker.Delete(jiraInstance.ID)
Identity.Delete(jiraBasicAuth.ID)
if keep, _ := strconv.ParseBool(Config.KEEP); keep {
return
}
Expect(Tracker.Delete(jiraInstance.ID)).To(Succeed())
Expect(Identity.Delete(jiraBasicAuth.ID)).To(Succeed())
})

Context("Create new Jira instance", func() {
Expand Down
8 changes: 7 additions & 1 deletion e2e/metrics/application_metrics.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package metrics

import (
"strconv"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

. "github.com/konveyor/go-konveyor-tests/config"
"github.com/konveyor/go-konveyor-tests/utils"
"github.com/konveyor/tackle2-hub/api"
)
Expand All @@ -23,6 +26,9 @@ var _ = Describe("Application Metrics", Ordered, func() {

AfterAll(func() {
// Resources cleanup
if keep, _ := strconv.ParseBool(Config.KEEP); keep {
return
}
utils.DeleteApplicationsBySlice(apps)
})

Expand All @@ -39,7 +45,7 @@ var _ = Describe("Application Metrics", Ordered, func() {
It("Should decrease the applications gauge", func() {
// Delete the last application item
lastApplicationItem := apps[len(apps)-1]
Application.Delete(lastApplicationItem.ID)
utils.DeleteApplicationsBySlice([]api.Application{lastApplicationItem})
metricValue--
Expect(GetMetricValue(metricName)).To(Equal(metricValue))
})
Expand Down
6 changes: 3 additions & 3 deletions utils/application_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/konveyor/go-konveyor-tests/data"
"github.com/konveyor/go-konveyor-tests/hack/uniq"
"github.com/konveyor/tackle2-hub/api"
. "github.com/onsi/gomega"
)

func CreateMultipleApplications(numberOfApplications int) []api.Application {
Expand All @@ -17,15 +18,14 @@ func CreateMultipleApplications(numberOfApplications int) []api.Application {
//// Create a local copy
application := data.ApplicationSamples[randomIndex]
uniq.ApplicationName(&application)
//// TODO: dealing with create returns error
Application.Create(&application)
Expect(Application.Create(&application)).To(Succeed())
appSlice = append(appSlice, application)
}
return appSlice
}

func DeleteApplicationsBySlice(apps []api.Application) {
for i := 0; i < len(apps); i++ {
Application.Delete(apps[i].ID)
Expect(Application.Delete(apps[i].ID)).To(Succeed())
}
}

0 comments on commit 790e00a

Please sign in to comment.