在单独的机器上运行bazel远程执行程序测试 [英] running bazel remote executor test on separate machines

查看:148
本文介绍了在单独的机器上运行bazel远程执行程序测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bazel的远程工作者指南(此处)说明如何在本地启动远程工作者,然后对它运行bazel.

The remote worker guide of bazel (here) explains how to start the remote-worker locally and then run bazel against it.

我尝试过并且确实有效(带有在GH中报告的错误)

I tried it and indeed that worked (with bugs that reported in GH)

另一种尝试是通过在docker容器中运行远程工作器并针对它运行bazel来在虚拟机上创建运行远程工作器.但是它以不同的方式失败了-我认为这次我使用的是错误的.

Another attempt was to create run the remote worker on a virtual separate machine, by running it inside docker container and running bazel against it. But it failed in a different way - and I think this time I'm using it wrong.

这是我的docker文件:

Here's my docker file:

FROM openjdk:8

# install release bazel from apt
RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
RUN curl https://bazel.build/bazel-release.pub.gpg |  apt-key add -
RUN apt-get update && apt-get install -y zip bazel

# compile dev bazel from sources
RUN mkdir -p /usr/src/bazel
# "bazel" has the latest development code of bazel from github
COPY bazel /usr/src/bazel
WORKDIR /usr/src/bazel
RUN bazel build src/bazel

# compile remote_worker using latest development bazel
RUN bazel-bin/src/bazel build //src/tools/remote_worker

# prepare cache folder
RUN mkdir -p /tmp/test

# Run remote-worker
CMD ["bazel-bin/src/tools/remote_worker/remote_worker","--work_path=/tmp/test","--listen_port=3030"]

构建后,我只运行了将端口绑定到本地主机的docker:

After building it I simply ran the docker binding the port to the localhost:

$ docker build -t bazel-worker .
$ docker run -p 3030:3030 bazel-worker

然后运行bazel Java测试以使用远程工作程序运行:(可以在此处签出我的测试仓库)

Then ran bazel java test to run using the remote worker: (Can check out my test repo here)

$ bazel --host_jvm_args=-Dbazel.DigestFunction=SHA1 test \
      --spawn_strategy=remote \
      --remote_executor=localhost:3030 \
      --remote_cache=localhost:3030 \
      --strategy=Javac=remote \
      --remote_local_fallback=false \
      --remote_timeout=600 \
      //src/main/java/com/example/...

但是我收到了这个奇怪的错误消息:

But I got this weird error message:

____Loading package: src/main/java/com/example
____Loading package: @bazel_tools//tools/cpp
____Loading package: @local_jdk//
____Loading package: @local_config_xcode//
____Loading package: @local_config_cc//
____Loading complete.  Analyzing...
____Loading package: tools/defaults
____Loading package: @bazel_tools//third_party/java/jdk/langtools
____Loading package: @junit//jar
____Found 1 test target...
____Building...
____[0 / 2] BazelWorkspaceStatusAction stable-status.txt
____[2 / 4] Creating source manifest for //src/main/java/com/example:my_test
____From Extracting interface @junit//jar:jar:
/tmp/test/build-80057300-ffd2-49ea-a20b-3f234d9963db/external/bazel_tools/tools/jdk/ijar/ijar: 1: /tmp/test/build-80057300-ffd2-49ea-a20b-3f234d9963db/external/bazel_tools/tools/jdk/ijar/ijar: �����0��!H__PAGEZEROx__TEXTpp__text__TEXT/��__stubs__TEXT0p�__stub_helper__TEXT���__gcc_except_tab__TEXT�: not found
/tmp/test/build-80057300-ffd2-49ea-a20b-3f234d9963db/external/bazel_tools/tools/jdk/ijar/ijar: 2: /tmp/test/build-80057300-ffd2-49ea-a20b-3f234d9963db/external/bazel_tools/tools/jdk/ijar/ijar: Syntax error: word unexpected (expecting ")")
ERROR: /private/var/tmp/_bazel_ors/719f891d5db9fd5e73ade25b0c847fd1/external/junit/jar/BUILD.bazel:2:1: output 'external/junit/jar/_ijar/jar/external/junit/jar/junit-4.12-ijar.jar' was not created.
ERROR: /private/var/tmp/_bazel_ors/719f891d5db9fd5e73ade25b0c847fd1/external/junit/jar/BUILD.bazel:2:1: not all outputs were created or valid.
____Building complete.
Target //src/main/java/com/example:my_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
____Elapsed time: 13.614s, Critical Path: 0.21s

我做错什么了吗?在实际(或虚拟)远程计算机上运行远程工作器时(相对于仅在本地运行),我需要以不同的方式运行它吗?

重要:我的机器是 mac osx sierra .,我相信docker openjdk:8 是基于ubuntu的,我正在本地运行bazel开发版本(sha 956810b6ee24289e457a4b8d0a84ff56eb32c264 ).

Important to mention: my machine is mac osx sierra. , I believe that docker openjdk:8 is ubuntu based, I'm running locally bazel development version (sha 956810b6ee24289e457a4b8d0a84ff56eb32c264).

推荐答案

在与Bazel本身不同的体系结构/操作系统组合上运行远程工作者尚无法正常工作.在Bazel中,我们还有几个地方可以检查本地机器-这些地方是作为临时措施添加的,但尚未修复.

Running the remote worker on a different architecture / OS combination than Bazel itself isn't working yet. We still have a couple of places in Bazel where we inspect the local machine - they were added as temporary measures, but haven't been fixed yet.

在某些情况下可能会起作用,尤其是对于平台无关的代码(例如Java或Scala).

It may work in some cases, especially for platform-independent code (e.g., Java or Scala).

如果您的构建需要大量测试,则可以尝试仅使用--test_strategy = remote远程运行测试;不过,我不确定默认的Jvm配置是否可以工作.

If your build is test-heavy, you could try only running tests remotely with --test_strategy=remote; I'm not sure if the default Jvm configuration will work, though.

如果要远程运行整个构建,则需要告诉Bazel它正在执行哪种机器/操作系统.现在,这需要设置--host_cpu,可能还需要设置--crosstool_top/--host_crosstool_top才能为该平台配置C ++编译器.

If you want to run the entire build remotely, then you need to tell Bazel what kind of machines / OS it's executing on. Right now, that'd require setting --host_cpu, and probably --crosstool_top / --host_crosstool_top to configure a C++ compiler for that platform.

此外,平台的某些组合工作的可能性越来越大.特别是,将MacOS和Linux或不同版本的Linux组合使用比Windows组合使用的可能性更大.

Also, some combinations of platforms are more and some less likely to work. In particular, combining MacOS and Linux or different flavors of Linux are much more likely to work than Windows in any combination.

这篇关于在单独的机器上运行bazel远程执行程序测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆