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

cmd: Add ref-id auto-discovery to resource upgrade #92

Merged

Conversation

karencfv
Copy link
Contributor

Description

Adds RefID auto-discovery when the --ref-id flag is not set.

Related Issues

Closes: #91

Motivation and Context

Fixes a bug where this value was not being auto-discovered as per the flag's description.

--ref-id string   Optional deployment RefId, if not set, the RefId will be auto-discovered

How Has This Been Tested?

Manually and with unit tests

$ go run main.go --config ce-aws deployment resource upgrade fba15d094a8a4a7983c32b7d0dc58596 --type apm --verbose
<...>
==================== Start of Request #2 ====================
POST /api/v1/deployments/fba15d094a8a4a7983c32b7d0dc58596/apm/main-apm/_upgrade?validate_only=false HTTP/1.1
<...>

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improves code quality but has no user-facing effect)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Readiness Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@karencfv karencfv added bug Something isn't working loe:small labels Dec 16, 2019
@karencfv karencfv requested a review from a team as a code owner December 16, 2019 01:42
@karencfv karencfv self-assigned this Dec 16, 2019
ppapapetrou76
ppapapetrou76 previously approved these changes Dec 16, 2019
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := UpgradeStateless(tt.args.params)
if !reflect.DeepEqual(err, tt.err) {
if tt.err != nil && err.Error() != tt.err.Error() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should settle on which error assertions we want to follow. It's not a big deal, but we're not asserting the same thing, an error could be returned by the function anyway and we wouldn't catch it unless there's something in the err field of the test structure, which won't be if the test structure is not asserting for an error different than nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer using !reflect.DeepEqual(err, tt.err) as well :) In this case, unfortunately, when I added the last test case I started getting the following error, so I had to change the assertion.

--- FAIL: TestUpgradeStateless/succeeds_when_RefID_is_not_set (0.00s)
    /Users/karen/go/src/github.com/elastic/ecctl/pkg/deployment/depresource/upgrade_stateless_test.go:172: UpgradeStateless() error = , wantErr <nil>

Copy link
Collaborator

Choose a reason for hiding this comment

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

huh that's weird

Copy link
Contributor

Choose a reason for hiding this comment

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

DeepEquals probably fails because the tests are of different type...

@karencfv
Copy link
Contributor Author

Updated the PR to use deployment.ResourceParams :) @ppapapetrou76 @marclop

@marclop marclop added this to the 33: Dec 04 - Dec 24 milestone Dec 17, 2019
@karencfv karencfv merged commit ce54eda into elastic:master Dec 17, 2019
@karencfv karencfv deleted the fix-resource-upgrade-refid-autodiscover branch December 17, 2019 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RefID is not auto-dicovered with ecctl deployment resource upgrade
3 participants