Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

Conversation

@cgonyeo
Copy link
Member

@cgonyeo cgonyeo commented Jul 8, 2016

This commit creates the directory lib/tests, which includes the
following:

  • code for generating a manifest and layers conforming to docker v2.2
  • code for emulating a docker registry that hosts these images (the
    docker daemon can successfully pull images from this)
  • a few tests that utilize these to test using the docker2aci library
    to pull/convert an image

These fetching tests triggered a panic in docker2aci, which this commit also fixes.

I intend to create a followup PR to also test the docker v2.1 logic and the logic for converting a file on disk, and to hopefully pull the logic under tests/ into these golang tests.

"github.com/appc/docker2aci/lib/internal/typesV2"
)

type Layer map[*tar.Header][]byte

Choose a reason for hiding this comment

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

This will use tar.Header pointer values as keys, not the tar.Header values. If put two equal values of tar.Header, but with distinct memory locations, they will have a different key.

Copy link
Member Author

Choose a reason for hiding this comment

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

When I make that change I get:

derek@proton ~/go/src/github.com/appc/docker2aci> go test -v github.com/appc/docker2aci/lib/tests
# github.com/appc/docker2aci/lib/tests                                                          
lib/tests/common.go:16: invalid map key type tar.Header

No clue why go doesn't allow this, but I don't think that using pointers will be an issue here. This is only used in the creation of tests, and test writers can avoid creating duplicate tar.Headers.

Choose a reason for hiding this comment

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

Ah, I overlooked you're trying to use stdlib's tar.Header as the key type. http://godoc.org/archive/tar#Header contains Xattrs of type map[string]string and that is the problem.

Map key types must have the comparison operators == and != fully defined, hence your struct key type must not contain a function, map, or slice.

I agree that this is used only in tests, but if you'll ever put two equal header values, but with different memory locations, they won't be the same :-/

Choose a reason for hiding this comment

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

Suggestion: can't you take the layer hashes as the map keys?

Copy link
Member Author

Choose a reason for hiding this comment

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

What I'm doing here is trying to work around the fact that Go doesn't have tuples. I want to store a list of pairs, where each pair is a tar header and the file contents. Go's maps kinda let me do this, by being a way to define a set of pairs (where each key and its value is the pair).

I could specify a struct that holds a tar.Header and a []byte, and have a layer be a slice of these structs, but that also would allow duplicate tar headers, so there's no benefit there over the current approach.

I don't think using layer hashes as the map keys here makes sense, as I don't know the hashes at this point in time and the keys here represent a given file in the layer, not the layer itself.

To truly prevent duplicates perhaps I could go with the slice of structs approach and have a helper function to search the slice each time to make sure that I'm not adding duplicates, but that seems rather heavy handed for hardcoded tests.

Choose a reason for hiding this comment

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

You are right about the layer hashes, it is too late to do reviews ;-) Let's leave it like this then.

If I'll come up with a better idea, I'll do a follow-up PR.

LGTM

@iaguis
Copy link
Member

iaguis commented Jul 11, 2016

We should run these tests on Semaphore

@iaguis iaguis added this to the v0.13.0 milestone Jul 11, 2016
@jonboulle
Copy link
Contributor

or Jenkins?

@iaguis
Copy link
Member

iaguis commented Jul 11, 2016

or Jenkins?

:trollface:

@jonboulle
Copy link
Contributor

not trolling :-(

On 11 July 2016 at 18:12, Iago López Galeiras [email protected]
wrote:

or Jenkins?

[image: :trollface:]


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#181 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ACewNyqZEIR77w0RRyxfd8SpGzhPucdiks5qUmtwgaJpZM4JIZuh
.

@iaguis
Copy link
Member

iaguis commented Jul 11, 2016

What's the benefit of running this on several distros?

@jonboulle
Copy link
Contributor

I don't think we need to do it on several different distros - but it would
be nice to move to a point where we don't need semaphore

On 11 July 2016 at 18:14, Iago López Galeiras [email protected]
wrote:

What's the benefit of running this on several distros?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#181 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ACewN6NLyfF4kovKWQyMsq5r-hfEPa_rks5qUmvrgaJpZM4JIZuh
.

@iaguis
Copy link
Member

iaguis commented Jul 11, 2016

I don't think we need to do it on several different distros - but it would
be nice to move to a point where we don't need semaphore

I don't see a pressing need for this, I think Semaphore works fine for docker2aci's use case.

@jonboulle
Copy link
Contributor

OK

On 11 July 2016 at 18:48, Iago López Galeiras [email protected]
wrote:

I don't think we need to do it on several different distros - but it would
be nice to move to a point where we don't need semaphore

I don't see a pressing need for this, I think Semaphore works fine for
docker2aci's use case.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#181 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ACewN0shbJvResCRHxeIhgZWBpb7YO9eks5qUnPdgaJpZM4JIZuh
.

@cgonyeo cgonyeo force-pushed the tests branch 2 times, most recently from 8c184d6 to d6e6537 Compare July 11, 2016 18:04
@cgonyeo
Copy link
Member Author

cgonyeo commented Jul 11, 2016

Added these tests to tests/test.sh, and they now get run by semaphore.

}

func GenerateDocker22(destPath string, img Docker22Image) error {
tmpDir, err := ioutil.TempDir("", "docker2aci-test-")
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to be used.

@iaguis
Copy link
Member

iaguis commented Jul 12, 2016

The tests don't check whether the converted image has the right contents, right?

I guess that's tested on the tests in tests/.

@cgonyeo
Copy link
Member Author

cgonyeo commented Jul 12, 2016

That's right, at this point these tests aim only to exercise the fetching logic. I'd like to move the checks under tests/ into these golang tests, but I figured it would be best to get this in before messing around with those for the sake of the docker2aci bump in rkt.

@iaguis
Copy link
Member

iaguis commented Jul 13, 2016

OK. Please remove the unused code I pointed out above and I'll merge it :)

This commit creates the directory lib/tests, which includes the
following:

 - code for generating a manifest and layers conforming to docker v2.2
 - code for emulating a docker registry that hosts these images (the
   docker daemon can successfully pull images from this)
 - a few tests that utilize these to test using the docker2aci library
   to pull/convert an image
@cgonyeo
Copy link
Member Author

cgonyeo commented Jul 13, 2016

Removed.

@iaguis iaguis merged commit aef3738 into appc:master Jul 14, 2016
@iaguis iaguis modified the milestones: v0.13.0, v0.12.1 Jul 14, 2016
@iaguis iaguis removed this from the v0.13.0 milestone Jul 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants