From 6a9f041eda1119c2dc060f55810ad3d556d56a4c Mon Sep 17 00:00:00 2001 From: Marek Aufart Date: Fri, 23 Jun 2023 08:56:20 +0200 Subject: [PATCH] Remove integration tests from Hub repo Integration E2E tests using API are now in https://github.com/konveyor/go-konveyor-tests those are executed using global CI workflows. Related to: - https://github.com/konveyor/tackle2-hub/issues/310 - https://github.com/konveyor/tackle2-hub/pull/418 Signed-off-by: Marek Aufart --- Makefile | 6 +- test/README.md | 6 +- test/integration/README.md | 5 - .../applications-inventory/analysis/pkg.go | 59 ---------- .../analysis/windup_basic_test.go | 103 ------------------ 5 files changed, 4 insertions(+), 175 deletions(-) delete mode 100644 test/integration/README.md delete mode 100644 test/integration/applications-inventory/analysis/pkg.go delete mode 100644 test/integration/applications-inventory/analysis/windup_basic_test.go diff --git a/Makefile b/Makefile index cda4e2415..8333d0856 100644 --- a/Makefile +++ b/Makefile @@ -131,12 +131,8 @@ test: test-api: HUB_BASE_URL=${HUB_BASE_URL} go test -count=1 -v ./test/api/... -# Run Hub API integration tests. -test-integration: - HUB_BASE_URL=${HUB_BASE_URL} go test -count=1 -v ./test/integration/... - # Run Hub test suite. -test-all: test-unit test-api test-integration +test-all: test-unit test-api migration: hack/next-migration.sh diff --git a/test/README.md b/test/README.md index a07db1191..c2fa8006c 100644 --- a/test/README.md +++ b/test/README.md @@ -3,18 +3,18 @@ Hub tests consist of following parts: - Unit tests ```$ make test``` - REST API tests ```$ make test-api``` -- Integration tests ```$ make test-integration``` -- WIP Export/import tests All tests can be executed with ```$ make test-all``` which will run all available tests. +For API E2E / integration tests, refer to https://github.com/konveyor/go-konveyor-tests + ## General information - Tests are written in golang to fit well to the Konveyor project components. - Each test is responsible for setup its test data and clean it when finished. - The main way of interacting with Hub is its API, to make testing easier, following tools are provided: - ```RichClient``` from [binding](https://github.com/konveyor/tackle2-hub/tree/main/binding) package that provides methods working with Hub resources (like ```RichClient.Application.Create(&testApp)```). This is a preffered option. - - ```addon.Client``` provides API methods like Get/Post/etc. it can be accessed from ```RichClient.Client()``` + - ```addon.Client``` provides API methods like Get/Post/etc. it can be accessed from ```RichClient.Client``` - ```test/assertion``` package provides Should/Must and other equality assertions. - Hub's ```API``` package provides predefined routes and resources struct definition. diff --git a/test/integration/README.md b/test/integration/README.md deleted file mode 100644 index 005f71809..000000000 --- a/test/integration/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# API Integration Tests - -Set of packages testing Hub functions together with other Konveyor components (requires full Konveyor installation to run). - -These test execution might take few minutes or more. diff --git a/test/integration/applications-inventory/analysis/pkg.go b/test/integration/applications-inventory/analysis/pkg.go deleted file mode 100644 index bdf3274ba..000000000 --- a/test/integration/applications-inventory/analysis/pkg.go +++ /dev/null @@ -1,59 +0,0 @@ -package analysis - -import ( - "os" - "path/filepath" - "regexp" - "testing" - "time" - - "github.com/konveyor/tackle2-hub/api" - "github.com/konveyor/tackle2-hub/binding" - "github.com/konveyor/tackle2-hub/test/api/client" - "github.com/konveyor/tackle2-hub/test/assert" -) - -var ( - // Setup Hub API client - Client *binding.Client - RichClient *binding.RichClient - - // Analysis waiting loop 5 minutes (60 * 5s) - Retry = 60 - Wait = 5 * time.Second -) - -func init() { - // Prepare RichClient and login to Hub API (configured from env variables). - RichClient = client.PrepareRichClient() - - // Access REST client directly (some test API call need it) - Client = RichClient.Client() -} - -// Test cases for Application Analysis. -type TC struct { - Name string - Application api.Application - Task api.Task - TaskData string - ReportContent map[string][]string -} - -func getReportText(t *testing.T, tc *TC, path string) (text string) { - // Get report file. - dirName, err := os.MkdirTemp("/tmp", tc.Name) - assert.Must(t, err) - fileName := filepath.Join(dirName, filepath.Base(path)) - err = RichClient.Application.Bucket(tc.Application.ID).Get(path, dirName) - assert.Must(t, err) - content, err := os.ReadFile(fileName) - assert.Must(t, err) - - // Prepare content - strip tags etc. - tags := regexp.MustCompile(`<.*?>`) - spaces := regexp.MustCompile(`(\t| +|\n\t+\n)`) - text = tags.ReplaceAllString(string(content), "") - text = spaces.ReplaceAllString(text, "") - return -} diff --git a/test/integration/applications-inventory/analysis/windup_basic_test.go b/test/integration/applications-inventory/analysis/windup_basic_test.go deleted file mode 100644 index 76786de4a..000000000 --- a/test/integration/applications-inventory/analysis/windup_basic_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package analysis - -import ( - "encoding/json" - "strings" - "testing" - "time" - - "github.com/konveyor/tackle2-hub/api" - "github.com/konveyor/tackle2-hub/test/api/application" - "github.com/konveyor/tackle2-hub/test/assert" -) - -// -// Test application analysis -// "Basic" means that there no other dependencies than the application itself (no need prepare credentials, proxy, etc) -func TestBasicAnalysis(t *testing.T) { - tests := []TC{ - { - Name: "Pathfinder cloud-readiness", - Application: application.PathfinderGit, - Task: api.Task{ - Addon: "windup", - State: "Ready", - }, - TaskData: `{ - "mode": { - "artifact": "", - "binary": false, - "withDeps": false, - "diva": true - }, - "output": "/windup/report", - "rules": { - "path": "", - "tags": { - "excluded": [ ] - } - }, - "scope": { - "packages": { - "excluded": [ ], - "included": [ ] - }, - "withKnown": false - }, - "sources": [ ], - "targets": [ - "cloud-readiness" - ] - }`, - ReportContent: map[string][]string { - "/windup/report/index.html": { - "5\nstory points", - "5\nCloud Mandatory", - "9\nInformation", - }, - }, - }, - } - - // Test using "richclient" methods (preffered way). - for _, tc := range tests { - t.Run(tc.Name, func(t *testing.T) { - // Create the application. - assert.Should(t, RichClient.Application.Create(&tc.Application)) - - // Prepare and submit the analyze task. - json.Unmarshal([]byte(tc.TaskData), &tc.Task.Data) - tc.Task.Application = &api.Ref{ID: tc.Application.ID} - assert.Should(t, RichClient.Task.Create(&tc.Task)) - - // Wait until task finishes - var task *api.Task - var err error - for i := 0; i < Retry; i++ { - task, err = RichClient.Task.Get(tc.Task.ID) - if err != nil || task.State == "Succeeded" || task.State == "Failed" { - break - } - time.Sleep(Wait) - } - - if task.State != "Succeeded" { - t.Errorf("Analyze Task failed. Details: %+v", task) - } - - // Check the report content. - for path, expectedElems := range tc.ReportContent { - content := getReportText(t, &tc, path) - // Check its content. - for _, expectedContent := range expectedElems { - if !strings.Contains(content, expectedContent) { - t.Errorf("Error report contect check for %s. Cannot find %s in %s", path, expectedContent, content) - } - } - } - - // Cleanup. - assert.Must(t, RichClient.Application.Delete(tc.Application.ID)) - }) - } -}