Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Initial Hub API Tests #268

Merged
merged 44 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8624f9d
Sample tests init
aufi Mar 13, 2023
8cbbdae
Update api test structure
aufi Mar 15, 2023
fcd1f41
Add Application API tests - initial part
aufi Mar 17, 2023
4826fba
Clean Application API test methods
aufi Mar 17, 2023
908286c
Update test client pkg
aufi Mar 20, 2023
368a743
Use api.Login in test client
aufi Mar 20, 2023
253a1b8
Avoid pkg global err
aufi Mar 21, 2023
b035ee8
Add TagCategory and Tag API tests
aufi Mar 21, 2023
addefad
Add StakeHolder group API test
aufi Mar 21, 2023
1e38d5b
Unify API tests variable naming
aufi Mar 22, 2023
9e0d7e7
Unify Api application test to be consistent
aufi Mar 22, 2023
30afe82
Use seed Categories in Tag test
aufi Mar 22, 2023
2b1e547
Add initial Stakeholder API test
aufi Mar 22, 2023
123b8b4
Add JobFunction and non-empty seed API test
aufi Mar 22, 2023
678be79
Update API test client
aufi Mar 24, 2023
99e7fa2
Update test fixtures creation
aufi Mar 27, 2023
f1b2282
Update addon Param public Inject
aufi Mar 27, 2023
86ed48d
Wrap addon Params in client
aufi Mar 28, 2023
661f262
Add unit auth tests to Makefile
aufi Mar 28, 2023
072e133
Use Must/Should error checks for fixtures
aufi Apr 5, 2023
427b194
Update Rich Client methods for resources
aufi Apr 6, 2023
9f9e554
Update tests readme
aufi Apr 6, 2023
1363e93
Add basic application analysis tests
aufi Apr 6, 2023
60da208
Update Makefile with integration
aufi Apr 6, 2023
9a26e95
Fix addon imports, HUB_BASE_URL
aufi Apr 11, 2023
64954cb
Move test assertions from client pkg
aufi Apr 14, 2023
1c3b13e
Remove test imports aliases
aufi Apr 14, 2023
80713e3
Update make test to run unit tests
aufi Apr 14, 2023
2e9ad8a
Update integration test and scheduled tests
aufi Apr 14, 2023
1e4edde
Try fix test in workflow
aufi Apr 14, 2023
1c43b4f
Update Makefile phony
aufi Apr 14, 2023
f2c8102
Fix Makefile .PHONY
aufi Apr 14, 2023
87acce0
Disable test-api workflow temporary
aufi Apr 14, 2023
67bc4b9
Un-alias client pkg in integration test
aufi Apr 14, 2023
7f71124
Update application create/get/list checks, bucket get
aufi Apr 19, 2023
c9e329f
Update test fixtures to map
aufi Apr 19, 2023
ba7f1f5
Update test samples to vars
aufi Apr 24, 2023
e9a4766
Start binding pkg with application RichClient
aufi Apr 28, 2023
ef59abc
Replace test/client for Application API test
aufi Apr 28, 2023
96f0789
Update binding RichClient initialization
aufi May 2, 2023
a00ef5c
Update binding richclient application methods
aufi May 3, 2023
228b623
Update Application fact API test
aufi May 3, 2023
56310a5
Add resources from api test to binding and test update
aufi May 4, 2023
33c4894
Update integration test with binding and minor fixed
aufi May 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ jobs:
- uses: actions/checkout@v3
- run: make podman-build

test-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- run: make test

#test-api:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v3
# with:
# go-version: '1.19'
# - run: |
# make vet
# make run &
# sleep 15 # probably a dirty solution
# HUB_BASE_URL=http://localhost:8080 make test-api

test-e2e:
runs-on: ubuntu-latest
steps:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/test-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test nightly

on:
schedule:
- cron: '13 0,12 * * *' # Regulary every 12 hours
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be more inclined for us to run all these tests post-merge to main.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK removing nightly build from this PR, but I believe that schedule-based application-level tests should run within the upstream CI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep for now to see how it works


jobs:
test-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Start minikube
uses: konveyor/tackle2-operator/.github/actions/start-minikube@main
- name: Build image in minikube
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
make docker-build
- name: Install Tackle
uses: konveyor/tackle2-operator/.github/actions/install-tackle@main
with:
tackle-hub-image: tackle2-hub:latest
tackle-image-pull-policy: IfNotPresent
- name: Set host and namespace
run: |
echo "host=$(minikube ip)/hub" >> $GITHUB_ENV
echo "namespace=$(kubectl get tackles.tackle.konveyor.io --all-namespaces --no-headers | awk '{print $1}')" >> $GITHUB_ENV
- name: Test execution
run: |
HUB_BASE_URL="http://$(minikube ip)/hub" make test-integration
with:
host: ${{ env.host }}
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
GOBIN ?= ${GOPATH}/bin
IMG ?= tackle2-hub:latest
HUB_BASE_URL ?= http://localhost:8080

PKG = ./addon/... \
./api/... \
Expand Down Expand Up @@ -116,3 +117,21 @@ ifeq (,$(wildcard $(INSTALL_TACKLE_SH)))
}
endif
$(INSTALL_TACKLE_SH);

# Run test targets always (not producing test dirs there).
.PHONY: test test-api test-integration

# Run unit tests.
test:
go test -v ./auth/
djzager marked this conversation as resolved.
Show resolved Hide resolved

# Run Hub REST API tests.
test-api:
HUB_BASE_URL=${HUB_BASE_URL} go test -v ./test/api/...

# Run Hub API integration tests.
test-integration:
HUB_BASE_URL=${HUB_BASE_URL} go test -v ./test/integration/...

# Run Hub test suite.
test-all: test-unit test-api test-integration
51 changes: 51 additions & 0 deletions binding/application.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package binding

import (
"github.com/konveyor/tackle2-hub/api"
)

//
// Application API.
type Application struct {
// hub API client.
client *Client
}
Copy link
Contributor

@jortel jortel May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binding should follow the same signature pattern as the addon binding.
Example:

  • Create(r *Application) (err error)
  • Get(int id) (r *Application, err error)
  • List() (list []api.Application, err error)
  • Update(r *Application) (err error)
  • Delete(int id) (err error)

In the future, the List() should also support filter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, will update binding pkg&tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Application methods in binding package were updated according to comment above.


//
// Create an Application.
func (h *Application) Create(r *api.Application) (err error) {
err = h.client.Post(api.ApplicationsRoot, &r)
return
}

//
// Get an Application by ID.
func (h *Application) Get(id uint) (r *api.Application, err error) {
r = &api.Application{}
path := Path(api.ApplicationRoot).Inject(Params{api.ID: id})
err = h.client.Get(path, r)
return
}

//
// List Applications.
func (h *Application) List() (list []api.Application, err error) {
list = []api.Application{}
err = h.client.Get(api.ApplicationsRoot, &list)
return
}

//
// Update an Application.
func (h *Application) Update(r *api.Application) (err error) {
path := Path(api.ApplicationRoot).Inject(Params{api.ID: r.ID})
err = h.client.Put(path, r)
return
}

//
// Delete an Application.
func (h *Application) Delete(id uint) (err error) {
err = h.client.Delete(Path(api.ApplicationRoot).Inject(Params{api.ID: id}))
return
}
51 changes: 51 additions & 0 deletions binding/businessservice.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package binding

import (
"github.com/konveyor/tackle2-hub/api"
)

//
// BusinessService API.
type BusinessService struct {
// hub API client.
client *Client
}

//
// Create a BusinessService.
func (h *BusinessService) Create(r *api.BusinessService) (err error) {
err = h.client.Post(api.BusinessServicesRoot, &r)
return
}

//
// Get a BusinessService by ID.
func (h *BusinessService) Get(id uint) (r *api.BusinessService, err error) {
r = &api.BusinessService{}
path := Path(api.BusinessServiceRoot).Inject(Params{api.ID: id})
err = h.client.Get(path, r)
return
}

//
// List BusinessServices.
func (h *BusinessService) List() (list []api.BusinessService, err error) {
list = []api.BusinessService{}
err = h.client.Get(api.BusinessServicesRoot, &list)
return
}

//
// Update a BusinessService.
func (h *BusinessService) Update(r *api.BusinessService) (err error) {
path := Path(api.BusinessServiceRoot).Inject(Params{api.ID: r.ID})
err = h.client.Put(path, r)
return
}

//
// Delete a BusinessService.
func (h *BusinessService) Delete(id uint) (err error) {
err = h.client.Delete(Path(api.BusinessServiceRoot).Inject(Params{api.ID: id}))
return
}
Loading