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

Fix missing configuration options panics #105

Merged
merged 3 commits into from
Apr 9, 2018

Conversation

AlfredBroda
Copy link
Contributor

Fixes #103.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.824% when pulling b5e486c on bugfix/use-mesosConfig-as-read-by-mesos-go into 9335d16 on master.

@janisz
Copy link
Contributor

janisz commented Mar 29, 2018

It does NOT fixes #103

@medzin
Copy link
Contributor

medzin commented Mar 29, 2018

@janisz can you explain why?

@janisz
Copy link
Contributor

janisz commented Mar 29, 2018

@medzin #103 (comment)

Copy link
Contributor

@medzin medzin left a comment

Choose a reason for hiding this comment

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

Let's add a test for this?

@AlfredBroda AlfredBroda force-pushed the bugfix/use-mesosConfig-as-read-by-mesos-go branch from b5e486c to e801906 Compare April 6, 2018 09:00
@codecov-io
Copy link

codecov-io commented Apr 6, 2018

Codecov Report

Merging #105 into master will increase coverage by 4.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
+ Coverage   69.25%   73.28%   +4.02%     
==========================================
  Files          34       34              
  Lines        1415     1430      +15     
==========================================
+ Hits          980     1048      +68     
+ Misses        363      307      -56     
- Partials       72       75       +3
Impacted Files Coverage Δ
executor.go 65.71% <100%> (+21.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update add8f4b...34e58da. Read the comment docs.

@medzin
Copy link
Contributor

medzin commented Apr 6, 2018

I do not see any tests added.


// then
assert.Error(t, err)
assert.Equal(t, "failed to re-establish subscription with agent within 1s, aborting", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we know that it will take exactly one second to produce error? In addition, why do we make an assertion for an error message? Changing the text is supposed to fail the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove this. The 1s in the error is the configured amount, so it does not change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

"github.com/stretchr/testify/assert"
)

func TestExecutorStartsWithoutCheckpointConfig(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

TestIf will look more sensible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@@ -0,0 +1,28 @@
package main
Copy link
Contributor

Choose a reason for hiding this comment

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

Add test case for no config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the case you mention covers this error too, so I will make the existing test more general (ie. test a no config situation).

@@ -101,8 +101,34 @@ func readConfiguration(config interface{}) {
}
}

func startExecutor(conf executor.Config) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this code to the executor package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would create an import cycle. Unless the hook code stays here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

err := startExecutor(conf)

// then
assert.Error(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need also a NotPanics assertion here - we fixing bug that code is panicking when some config options are missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@AlfredBroda AlfredBroda force-pushed the bugfix/use-mesosConfig-as-read-by-mesos-go branch 2 times, most recently from 444199b to 9a06ada Compare April 9, 2018 08:13
@AlfredBroda AlfredBroda changed the title Assign MesosConfig as read by mesos-go Fix missing configuration options panics Apr 9, 2018
@AlfredBroda AlfredBroda force-pushed the bugfix/use-mesosConfig-as-read-by-mesos-go branch from 9a06ada to 34e58da Compare April 9, 2018 08:43
@@ -382,6 +381,12 @@ func TestIfNotPanicsWhenKillWithoutLaunch(t *testing.T) {
})
}

func TestIfExecutorStartsWithoutConfig(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It should just start and don't panic or return error also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, my guess is it just should not panic. The reason for what Janisz reported was that the backoff notifier swaps minWait and maxWait if it compares them and finds maxWait to be lesser of the two. So we just had to make sure that we pass in the correct value for SubscriptionBackoffMax. This part of Config had no rules defining the defaults, and the minWait is hardcoded to time.Second - so I just check if max is less and assign a default value.

@AlfredBroda AlfredBroda merged commit 0d1e155 into master Apr 9, 2018
@medzin medzin deleted the bugfix/use-mesosConfig-as-read-by-mesos-go branch April 27, 2018 10:08
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.

None yet

6 participants