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

Run tests on arm64 as well #600

Merged
merged 3 commits into from
Oct 1, 2020

Conversation

mattmoor
Copy link
Contributor

@mattmoor mattmoor commented Sep 29, 2020

Enable travis builds of arm64 in addition to amd64, and extend the multi-arch support to include everything under //base, including the container_test rules.

This required quite a few changes across a number of repos. Thanks to @nkubala for the quick turnaround on PRs to the structure test repo, and the 1.9.1 release. The one outstanding PR is to pull the 1.9.1 release into rules_docker here: bazelbuild/rules_docker#1639.

Unfortunately, Bazel's support for filtering targets by architecture is still pretty weak. I tried a half dozen options from constraints (restricted_to) to config settings (select) and at best I could make the targets on mismatched platforms emit an error, but Bazel doesn't yet support filtering them (and the issue is >3 years old).

The workaround I was able to find is similar to how Google runs integration testing internally, which is to tag the tests as tags = ["manual"] and then to run specific targets, however, I also included the architecture the test is expected to run on, e.g. tags = ["manual", "amd64"]. Then in Travis I use bazel query to pull out all of the appropriate tests for each architecture and run them explicitly. This required me to tag all of the existing tests (that haven't moved) as amd64 explicitly, but as we move these to loops over ARCHITECTURES we would use the appropriate architecture and the arm64 support should "just work" 🤞

We shouldn't merge this until I'm able to rebase on the merged rules_docker PR, but I'd appreciate it if folks would take a look and leave any other comments they might have. 🙏

@googlebot googlebot added the cla: yes CLAs look good label Sep 29, 2020
@mattmoor mattmoor force-pushed the multi-arch branch 15 times, most recently from fe2b82b to 21a2ff9 Compare October 1, 2020 01:59
examples/rust/BUILD Outdated Show resolved Hide resolved
@mattmoor mattmoor changed the title [WIP] Run tests on arm64 as well Run tests on arm64 as well Oct 1, 2020
@mattmoor mattmoor requested review from chanseokoh and dlorenc October 1, 2020 14:20
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 is cool stuff!

I don't have much expertise in Bazel, so Unfortunately I cannot comment on what would be the best approach to build and test based on the environment. (Strange, I feel like this kind of feature should be a basic component in any testing frameworks.) But as long as it works, this is a great progress.

WORKSPACE Outdated Show resolved Hide resolved
cc/BUILD Outdated Show resolved Hide resolved
cpus/BUILD Outdated Show resolved Hide resolved
cloudbuild.yaml Outdated
Comment on lines 89 to 92
docker tag bazel/base:base_root_arm64_debian9 gcr.io/$PROJECT_ID/base:latest-arm64
docker tag bazel/base:base_root_arm64_debian9 gcr.io/$PROJECT_ID/base:nonroot-arm64
docker tag bazel/base:debug_root_arm64_debian9 gcr.io/$PROJECT_ID/base:debug-arm64
docker tag bazel/base:debug_root_arm64_debian9 gcr.io/$PROJECT_ID/base:debug-nonroot-arm64
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
docker tag bazel/base:base_root_arm64_debian9 gcr.io/$PROJECT_ID/base:latest-arm64
docker tag bazel/base:base_root_arm64_debian9 gcr.io/$PROJECT_ID/base:nonroot-arm64
docker tag bazel/base:debug_root_arm64_debian9 gcr.io/$PROJECT_ID/base:debug-arm64
docker tag bazel/base:debug_root_arm64_debian9 gcr.io/$PROJECT_ID/base:debug-nonroot-arm64
docker tag bazel/base:base_root_arm64_debian9 gcr.io/$PROJECT_ID/base:latest-arm64
docker tag bazel/base:base_nonroot_arm64_debian9 gcr.io/$PROJECT_ID/base:nonroot-arm64
docker tag bazel/base:debug_root_arm64_debian9 gcr.io/$PROJECT_ID/base:debug-arm64
docker tag bazel/base:debug_nonroot_arm64_debian9 gcr.io/$PROJECT_ID/base:debug-nonroot-arm64

And likewise, eventually we should also tag these in -debian9.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! re: -debian9 I think we need a better strategy for scripting the variants, but totally agree. This is quite tedious to keep straight as-is 😅

docker tag bazel/base:base_root_amd64_debian9 gcr.io/$PROJECT_ID/base:${COMMIT_SHA}
docker tag bazel/base:base_root_amd64_debian9 gcr.io/$PROJECT_ID/base:latest-amd64
docker tag bazel/base:base_root_amd64_debian9 gcr.io/$PROJECT_ID/base-debian9:${COMMIT_SHA}
docker tag bazel/base:base_root_amd64_debian9 gcr.io/$PROJECT_ID/base-debian9:latest
Copy link
Member

Choose a reason for hiding this comment

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

Ideally and eventually, I think this should be a manifest list. We've maintained that base and base-debian9 are basically identical. (And same for -debian10.) But I guess you're adding manifest lists only to base as a start?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wanted to plumb through the main things for each first. I think we need a bigger discussion around how we (likely) script these variations to cut down on the boilerplate (and sorts of errors I had above)

@mattmoor
Copy link
Contributor Author

mattmoor commented Oct 1, 2020

I pushed a commit with the couple edits called out. I added the debian9/10 variant topic to my list. Once I land the open chain I'll open issues for the remaining pieces of work on my radar (java, node, dotnet, this, other architectures like ppc and s390x).

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.

Looks good to me.

name = "debug_" + user + "_" + arch + distro_suffix,
architecture = arch,
base = ":base_" + user + "_" + arch + distro_suffix,
directory = "/",
Copy link
Member

Choose a reason for hiding this comment

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

Maybe directory is unnecessary, as it's default is /?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is just an indentation thing, I didn't change this.

container_test(
name = "openssl_" + arch + distro_suffix + "_test",
configs = ["testdata/certs.yaml"],
image = ":base_root_" + arch + distro_suffix,
Copy link
Member

Choose a reason for hiding this comment

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

Is it meaningful to parameterize user (here and tests below) given that we're in a loop, or it is not worth?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could look at doing this more, it wasn't clear to me if/which of these tests might do something privileged, so I tried to avoid creeping the scope too much.

The one thing I did make a point to do was make the pure-go test use static, which I believe previously had zero direct test coverage.

@mattmoor
Copy link
Contributor Author

mattmoor commented Oct 1, 2020

@chanseokoh if it's alright I am going to punt on further churn here (since both are pre-existing limitations, and I want to maintain sanity rebasing the other changes), but I agree with the cleanups / experiments you suggest.

I can try to follow up with these on top of the fuller chain of changes 🙏

@mattmoor
Copy link
Contributor Author

mattmoor commented Oct 1, 2020

Note: there are some other funny warts I haven't addressed, like plumbing root/nonroot through all the variants (I don't think //cc or python2.7 have it, but python3 does).

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.

Sounds good! Thanks for the awesome work.

@mattmoor mattmoor merged commit 34b23ec into GoogleContainerTools:master Oct 1, 2020
@mattmoor mattmoor deleted the multi-arch branch October 1, 2020 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes CLAs look good
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants