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

Separate out project dependencies, add integration test to verify #1785

Merged
merged 4 commits into from
Jun 20, 2019

Conversation

loosebazooka
Copy link
Member

Uh so here's the PR with the weirdo test. Basically injecting a task to inspect the layer configuration state and outputting it so the test can pick it up and verify. I don't know how else to do it without mocking the world.

@chanseokoh
Copy link
Member

jib-gradle-plugin/src/test/resources/gradle/projects/multi-service/complex-service/libs/dependency-1.0.0.jar
jib-gradle-plugin/src/test/resources/gradle/projects/multi-service/complex-service/libs/dependencyX-1.0.0-SNAPSHOT.jar

There files are added accidentally, aren't they? (Note multi-service, not all-local-multi-service.)

@loosebazooka
Copy link
Member Author

loosebazooka commented Jun 19, 2019

There files are added accidentally, aren't they? (Note multi-service, not all-local-multi-service.)

oh right yeah. I'll clean that up. I'm mostly curious what people think of this test.

@chanseokoh
Copy link
Member

chanseokoh commented Jun 19, 2019

How about these?

  1. We already have code that opens an image tar, goes through all the layers inside the tar (the code assumes all .tar.gz files in the image tar are layer tars), opens the embedded layer tars, and lists all the files in each layer:
    https://github.com/GoogleContainerTools/jib/blob/v1.3.0-maven/jib-core/src/integration-test/java/com/google/cloud/tools/jib/api/ReproducibleImageTest.java#L137
    We won't be able to explicitly verify layer types this way, but I think it is enough to check the order of dependency layers.

  2. Or add some code somewhere to log files in each layer as DEBUG.

@loosebazooka
Copy link
Member Author

What about a task _jibDebugShowBuildConfiguration or something instead of (2).

@chanseokoh
Copy link
Member

I actually prefer (1). It doesn't look crazy, we already have the code, and it doesn't add any new production code. To me, _jibDebugShowBuildConfiguration seems more code to maintain.

@TadCordle
Copy link
Contributor

Also running tasks/goals in tests is a pretty big slow down, which can be annoying.

@loosebazooka
Copy link
Member Author

Well I still need to load the project context which is what I'm explicitly testing here. I can trust (from gradle) that JavaContainerBuilder is doing the right thing. What I need to know is that the gradle plugin code is doing the right things splitting the dependencies.

@loosebazooka loosebazooka changed the title Separate out project dependencies, add crazy test to verify Separate out project dependencies, add integration test to verify Jun 20, 2019
@loosebazooka
Copy link
Member Author

Pushed a new less ridiculous test.

artifact ->
artifact.getId().getComponentIdentifier()
instanceof ProjectComponentIdentifier)
.map(ResolvedArtifact::getFile)
Copy link
Member

Choose a reason for hiding this comment

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

This is unclear, but should we do filter(File::exists)? For what I know, if do the filtering for allFiles and classesOutputDirectories. (JavaContainerBuilder does the check and throws NoSuchFileException, which might be a good thing actually. It's unclear to me if this can ever happen.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I think it's safer to not filter, if we have an issue in the configuration, it should pick it up. File::exists will just quietly ignore the error.

Copy link
Member

@chanseokoh chanseokoh left a comment

Choose a reason for hiding this comment

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

This looks good. I think the test worked out nicely.

@loosebazooka loosebazooka merged commit ecd1fcc into master Jun 20, 2019
@chanseokoh chanseokoh deleted the gradleProjectDependencies branch June 20, 2019 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants