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

Integration test refactoring #126

Merged
merged 38 commits into from
May 15, 2018

Conversation

sharifelgamal
Copy link
Contributor

No description provided.

t.FailNow()
}

_, ex, _, _ := runtime.Caller(0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit weird, could you use os.Args[0] instead?
https://golang.org/pkg/os/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

os.Args gives me where the test file is actually being run, which is in a tmp folder somewhere. I actually want to access the directory where the go file actually lives, which is what runtime.Caller gives.

cwd := filepath.Dir(ex)

// Grab the latest container-diff binary
getContainerDiff := exec.Command("gsutil", "cp", "gs://container-diff/latest/container-diff-linux-amd64", ".")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's just require that container-diff is on the path.

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

}


for _, dockerfile := range dockerfiles {
Copy link
Collaborator

Choose a reason for hiding this comment

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

filepath.Glob might be easier than ls'ing everything and filtering 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.

yep. done.

"-c", buildContextPath,
)

err = kanikoCmd.Run()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: a small helper that takes the cmd and t and does this could be useful.

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.

@dlorenc
Copy link
Collaborator

dlorenc commented May 3, 2018

Looks like we'll have to move the container-diff installation piece to the kokoro setup (or the container that will run in GCB)

@sharifelgamal sharifelgamal changed the title WIP: integration test refactoring Integration test refactoring May 14, 2018
@sharifelgamal
Copy link
Contributor Author

This is ready for a look.

Copy link
Collaborator

@dlorenc dlorenc left a comment

Choose a reason for hiding this comment

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

A few nits. Nice job.

}

// Make sure container-diff is on user's PATH
err = exec.Command("container-diff").Run()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: exec.LookPath would probably be a bit easier 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

for _, dockerfile := range dockerfiles {
t.Run("test_"+dockerfile, func(t *testing.T) {
dockerfile = dockerfile[len("dockerfile/")+1:]
fmt.Printf("%s\n", dockerfile)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: t.Log here instead of fmt.Print

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


// container-diff
daemonDockerImage := daemonPrefix + dockerImage
//daemonKanikoImage := daemonPrefix + kanikoImage
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this

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

@sharifelgamal sharifelgamal merged commit f8aa88b into GoogleContainerTools:master May 15, 2018
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.

2 participants