kubebb / core

A declarative component lifecycle management platform
https://kubebb.github.io/website
Apache License 2.0
8 stars 9 forks source link

feat: add portal_controller.go and two portal.yaml for testing #259

Closed Henry-Gao-2004 closed 1 year ago

Henry-Gao-2004 commented 1 year ago

What type of PR is this?

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #225

Special notes for your reviewer

Two new fields are added in Portal. Duplicate bool json:"duplicate" ConflictedPortals []string json:"conflicted-portals"

duplicate is true when there is at least one duplicate in the client. ConflictedPortals is a list of namespacedname of portals that are equivalent to the current portal.

An example of error message: 1.6920898037031348e+09 ERROR found portals with duplicate path and entry {"controller": "portal", "controllerGroup": "core.kubebb.k8s.com.cn", "controllerKind": "Portal", "portal": {"name":"portal-example-duplicate"}, "namespace": "", "name": "portal-example-duplicate", "reconcileID": "c30349bb-67c2-4234-add5-e434ce3b1bfa", "duplicates": ["/portal-example"], "error": "duplicate error"}

Two portal.yaml are also added for testing.

codecov[bot] commented 1 year ago

Codecov Report

Merging #259 (2cc50cf) into main (1d70d6c) will decrease coverage by 0.49%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #259      +/-   ##
==========================================
- Coverage   17.40%   16.92%   -0.49%     
==========================================
  Files          33       34       +1     
  Lines        3274     3367      +93     
==========================================
  Hits          570      570              
- Misses       2671     2764      +93     
  Partials       33       33              
Files Changed Coverage Δ
api/v1alpha1/portal_types.go 100.00% <ø> (ø)
controllers/portal_controller.go 0.00% <0.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

bjwswang commented 1 year ago

@Henry-Gao-2004 Since you add two test yamls,pls update example-test too.

Abirdcfly commented 1 year ago

There is a missing case here:

  1. create A
  2. create duplicate B. B will be marked as a duplicate, which is correct.
  3. deleting A, the duplicate marking of B should be cleared.
Henry-Gao-2004 commented 1 year ago

@Henry-Gao-2004 Since you add two test yamls,pls update example-test too.

The example-test.sh is now updated! There are three test cases: ~ Check if two different portals will detect duplicates (they should not) ~ Check if two portals with the same path and entry can have correct status ~ Check if a portal will be updated when its duplicate is deleted

There is a missing case here:

Thank you! The missing case is now tested in test 7.3!

Some updates:

Portal.Status.ConflictedPortals is now a string instead of string array. Each segment is separated by a semicolon (":"). Portal.Status.ConflictedPortals in json is now "conflicted" instead of "conflicted-portals". One more parameter "init" is passed to checkDuplicate() in order to avoid infinite loop.