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 code and unit tests to successfully run on Go 1.10 #7610

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Fix code and unit tests to successfully run on Go 1.10 #7610

wants to merge 4 commits into from

Conversation

vburenin
Copy link
Contributor

Fixes: #7609

@codecov-io
Copy link

codecov-io commented Mar 29, 2018

Codecov Report

Merging #7610 into master will increase coverage by 0.05%.
The diff coverage is 67.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7610      +/-   ##
==========================================
+ Coverage   31.41%   31.47%   +0.05%     
==========================================
  Files         282      281       -1     
  Lines       42152    42027     -125     
==========================================
- Hits        13244    13228      -16     
+ Misses      27750    27637     -113     
- Partials     1158     1162       +4
Impacted Files Coverage Δ
pkg/dio/writer.go 55.95% <67.85%> (-5.22%) ⬇️
cmd/vic-machine/create/create.go 40.9% <0%> (-0.7%) ⬇️
lib/install/management/configure.go 7.19% <0%> (-0.1%) ⬇️
cmd/vic-machine/delete/delete.go
lib/portlayer/attach/communication/interactor.go 27% <0%> (+2.91%) ⬆️
pkg/logmgr/logmgr.go 65.97% <0%> (+3.47%) ⬆️
lib/portlayer/attach/communication/connector.go 61.68% <0%> (+6.23%) ⬆️
lib/portlayer/attach/communication/lazy.go 90.9% <0%> (+22.72%) ⬆️

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 2102886...daea638. Read the comment docs.

copy(w, writers)
t := &multiWriter{writers: w}

t := &multiWriter{writers: writers}
Copy link
Contributor

Choose a reason for hiding this comment

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

huh, interesting. Why is this copy unnecessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the answer to that could just be "because it is, and it wasn't needed in the first place"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

@gigawhitlocks
Copy link
Contributor

Probably want @matthewavery to have a look at this too

@@ -141,39 +120,35 @@ func (t *multiWriter) Close() error {
return nil
}

// TODO: add a ReadFrom for more efficient copy
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove the TODO here? it is still a function that would be nice to have.

if w == writer {
t.writers = append(t.writers[:i], t.writers[i+1:]...)
if verbose {
log.Debugf("[%p] removed writer - now %d writers", t, len(t.writers))
Copy link
Contributor

Choose a reason for hiding this comment

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

having a verbose debug of every wrtier that is left after the removal of one is still useful. just in the case that something is getting removed when it should not(for whatever reason).

Copy link
Contributor

Choose a reason for hiding this comment

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

woops meant this for 2 lines down. sorry.

@@ -132,17 +132,19 @@ func TestSingleStripper(t *testing.T) {
}

// make the buf just that little bit bigger to allow for errrors in the copy if they would occur
buf := make([]byte, size+10)
buf := make([]byte, size)
Copy link
Member

Choose a reason for hiding this comment

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

you need to remove the comment above if you've dropped the extra spacing. Why did you drop the extra spacing?

n, err := tr.Read(buf)

if !assert.NoError(t, err, "No expected errors from file data copy") {
if !assert.Equal(t, n, size, "Expected file data size to match target generated size") {
Copy link
Member

Choose a reason for hiding this comment

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

There is a require that can be used instead of assert now, which does FailNow if the assertion fails. Simplifies the code significantly.

if n != size {
panic(fmt.Sprintf("Failed to write all bytes: %d != %d", n, size))
}
for i := 0; i < num; i++ {
Copy link
Member

Choose a reason for hiding this comment

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

Why are we removing the goroutine? The goroutine doesn't have that much of an effect in the test, but it's a better representation of how it gets used in reality.

// Remove grabs the lock
t.Remove(w)

t.remove(w)
Copy link
Member

Choose a reason for hiding this comment

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

remove no longer grabs the lock - please make sure you update comments if you're changing behaviour as this gets very, very confusing.


eof := 0
// possibly want to add buffering or parallelize this
for _, w := range wTmp {
for _, w := range t.writers {
n, err = w.Write(p)
Copy link
Member

Choose a reason for hiding this comment

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

If I recall correctly this call can block depending on the Writer type - this is one of the reasons that we didn't hold the lock while performing the write.

What is the purpose and intent behind removing all of the parallelism from these tests? Generally that's where we would observe the most issues so this seems to be reducing the efficacy of the tests. And in this specific case, of the functional package code as well.

@zjs zjs mentioned this pull request Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants