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

refactor: split packages #85

Merged
merged 48 commits into from
Jul 11, 2024
Merged

refactor: split packages #85

merged 48 commits into from
Jul 11, 2024

Conversation

keroxp
Copy link
Member

@keroxp keroxp commented Jun 27, 2024

This PR includes various changes across the package. Mainly, the most part of cage were split into sub packages for unit test convenience.

  • task: codes for canary test, both ALB test and simple wait test
  • taskset: an abstraction of combined tasks for single service
  • rollout: a core logic part of cage rollout
  • types: common interfaces
  • env: environment variables

logos/di introduction

We are now using logos/di for dependency management.

Rewritten tests

Almost all tests have been rewritten, based on the policy below:

  • detailed unit tests with gomock for sub packages, no test pacgaes
  • integration tests with test package and failure tests with gomock for cage package

Now, I chose the same package for unit test codes not _test: to simulate failures that depends on internal state

Other changes

  • all cage commands skip loading task definition file if --taskDefinitionArn opt provided.
  • The default value for --canaryIdleDuration changed to 15 seconds.
  • fixed missing condition check that canary task has two or more attachments except ElasticNetworkInterface

Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 97.52066% with 15 lines in your changes missing coverage. Please review.

Project coverage is 88.35%. Comparing base (ace2c1f) to head (65afc07).

Files Patch % Lines
env/env.go 80.55% 3 Missing and 4 partials ⚠️
cli/cage/commands/command.go 64.70% 1 Missing and 5 partials ⚠️
up.go 88.23% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #85       +/-   ##
===========================================
+ Coverage   74.36%   88.35%   +13.99%     
===========================================
  Files          18       21        +3     
  Lines         987     1065       +78     
===========================================
+ Hits          734      941      +207     
+ Misses        145       61       -84     
+ Partials      108       63       -45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@keroxp keroxp changed the title feat: canary test for service registry service refactor: split packages Jul 2, 2024
@keroxp keroxp requested review from takkyuuplayer and alfnets July 8, 2024 05:41
@keroxp keroxp marked this pull request as ready for review July 8, 2024 05:41
key/keys.go Show resolved Hide resolved
export_test.go Outdated Show resolved Hide resolved
env/env.go Outdated Show resolved Hide resolved
env/env.go Outdated Show resolved Hide resolved
Copy link

@alfnets alfnets left a comment

Choose a reason for hiding this comment

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

In my review, I've only noted one point. The changes have made the errors and process more understandable. The adoption of dependency injection has contributed to streamlining the code. Nice work!

env/env.go Outdated
if noSvc != nil || noTd != nil {
return nil, nil, xerrors.Errorf("roll out context specified at '%s' but no 'service.json' or 'task-definition.json'", dir)
if noSvc != nil {
return nil, xerrors.Errorf("roll out context specified at '%s' but no 'service.json' or 'task-definition.json'", dir)
Copy link

Choose a reason for hiding this comment

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

It would be better to update the error messages in the LoadServiceDefinition and LoadTaskDefinition functions to specify the corresponding missing files.

Suggested change
return nil, xerrors.Errorf("roll out context specified at '%s' but no 'service.json' or 'task-definition.json'", dir)
return nil, xerrors.Errorf("roll out context specified at '%s' but no 'service.json'", dir)

env/env.go Outdated
_, noTd := os.Stat(tdPath)
var td ecs.RegisterTaskDefinitionInput
if noTd != nil {
return nil, xerrors.Errorf("roll out context specified at '%s' but no 'service.json' or 'task-definition.json'", dir)
Copy link

Choose a reason for hiding this comment

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

Suggested change
return nil, xerrors.Errorf("roll out context specified at '%s' but no 'service.json' or 'task-definition.json'", dir)
return nil, xerrors.Errorf("roll out context specified at '%s' but no 'task-definition.json'", dir)

Comment on lines +45 to +48
} else if err := canaryTasks.Cleanup(ctx); err != nil {
log.Errorf("failed to cleanup canary tasks due to: %s", err)
lastErr = err
}
Copy link

Choose a reason for hiding this comment

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

👍

@keroxp keroxp requested review from alfnets and takkyuuplayer July 10, 2024 11:56
Copy link

@alfnets alfnets left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

Copy link
Contributor

@takkyuuplayer takkyuuplayer left a comment

Choose a reason for hiding this comment

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

LGTM!

@takkyuuplayer takkyuuplayer merged commit 196daa5 into main Jul 11, 2024
3 checks passed
@takkyuuplayer takkyuuplayer deleted the feat-registry-test branch July 11, 2024 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants