Skip to content

test framework compatible with m1 arm64#322

Closed
zhyyu wants to merge 7 commits intoapache:mainfrom
zhyyu:feature-compatible-with-m1
Closed

test framework compatible with m1 arm64#322
zhyyu wants to merge 7 commits intoapache:mainfrom
zhyyu:feature-compatible-with-m1

Conversation

@zhyyu
Copy link
Copy Markdown
Contributor

@zhyyu zhyyu commented Sep 28, 2022

  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
  • Update the CHANGES log.

@zhyyu zhyyu changed the title compatible with m1 arm64 test framework compatible with m1 arm64 Sep 28, 2022
Comment thread test/plugin/run.sh Outdated
@wu-sheng wu-sheng added enhancement New feature or request CI Setting labels Sep 28, 2022
@wu-sheng wu-sheng added this to the 8.13.0 milestone Sep 28, 2022
@wu-sheng
Copy link
Copy Markdown
Member

2022-09-28T08:59:21.1450158Z [INFO] Copying files to /home/runner/work/skywalking-java/skywalking-java/test/plugin/containers/jvm-container/target/docker/skywalking/agent-test-jvm/1.0.0/build/maven
2022-09-28T08:59:21.1703577Z [INFO] Building tar: /home/runner/work/skywalking-java/skywalking-java/test/plugin/containers/jvm-container/target/docker/skywalking/agent-test-jvm/1.0.0/tmp/docker-build.tar
2022-09-28T08:59:21.2850662Z [INFO] DOCKER> [skywalking/agent-test-jvm:1.0.0]: Created docker-build.tar in 143 milliseconds
2022-09-28T08:59:25.3836083Z [ERROR] DOCKER> Unable to build image [skywalking/agent-test-jvm:1.0.0] : "The command '/bin/sh -c apt-get update -y' returned a non-zero code: 127"  ["The command '/bin/sh -c apt-get update -y' returned a non-zero code: 127" ]

Build image failure from the CI process.

@zhyyu
Copy link
Copy Markdown
Contributor Author

zhyyu commented Sep 28, 2022

2022-09-28T08:59:21.1450158Z [INFO] Copying files to /home/runner/work/skywalking-java/skywalking-java/test/plugin/containers/jvm-container/target/docker/skywalking/agent-test-jvm/1.0.0/build/maven
2022-09-28T08:59:21.1703577Z [INFO] Building tar: /home/runner/work/skywalking-java/skywalking-java/test/plugin/containers/jvm-container/target/docker/skywalking/agent-test-jvm/1.0.0/tmp/docker-build.tar
2022-09-28T08:59:21.2850662Z [INFO] DOCKER> [skywalking/agent-test-jvm:1.0.0]: Created docker-build.tar in 143 milliseconds
2022-09-28T08:59:25.3836083Z [ERROR] DOCKER> Unable to build image [skywalking/agent-test-jvm:1.0.0] : "The command '/bin/sh -c apt-get update -y' returned a non-zero code: 127"  ["The command '/bin/sh -c apt-get update -y' returned a non-zero code: 127" ]

Build image failure from the CI process.

  [INFO] DOCKER> Pulled adoptopenjdk/openjdk8:alpine in 6 seconds 
  Error:  DOCKER> Unable to build image [skywalking/agent-test-jvm:1.0.0] : "The command '/bin/sh -c apt-get update -y' returned a non-zero code: 127"  ["The command '/bin/sh -c apt-get update -y' returned a non-zero code: 127" ]
  [INFO] ------------------------------------------------------------------------
  [INFO] Reactor Summary for SkyWalking Plugins Tests 1.0.0:

It's still adoptopenjdk/openjdk8:alpine, I will change .github CI and retry.

@zhyyu
Copy link
Copy Markdown
Contributor Author

zhyyu commented Sep 30, 2022

m1 arm64 have to excute

socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock
export DOCKER_HOST=tcp://127.0.0.1:2375

before run

bash ./test/plugin/run.sh -f ${scenario_name}

@wu-sheng
Copy link
Copy Markdown
Member

You could use shell to check and run more.

@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Oct 9, 2022

@zhyyu Would you continue this?

@zhyyu
Copy link
Copy Markdown
Contributor Author

zhyyu commented Oct 11, 2022

@zhyyu Would you continue this?

Yes, I will continue. These days my work is busy, I will go on when I am free.

@zhyyu
Copy link
Copy Markdown
Contributor Author

zhyyu commented Oct 11, 2022

The m1 user have to install socat.

@wu-sheng
Copy link
Copy Markdown
Member

You could add through CI, and update docs to help on local use.

Comment thread test/plugin/containers/jvm-container/pom.xml
@kezhenxu94
Copy link
Copy Markdown
Member

m1 arm64 have to excute

socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock
export DOCKER_HOST=tcp://127.0.0.1:2375

before run

bash ./test/plugin/run.sh -f ${scenario_name}

Can you explain or paste some related links about why the socat command is needed?

@zhyyu
Copy link
Copy Markdown
Contributor Author

zhyyu commented Oct 12, 2022

m1 arm64 have to excute

socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock
export DOCKER_HOST=tcp://127.0.0.1:2375

before run

bash ./test/plugin/run.sh -f ${scenario_name}

Can you explain or paste some related links about why the socat command is needed?

https://stackoverflow.com/questions/71300031/docker-image-build-failed-on-mac-m1-chip , the second answer

https://juejin.cn/post/7094919855643557896

https://nxt.engineering/blog/kafka-docker-image/

https://dmp.fabric8.io/ the 3. Global configuration section, DOCKER_HOST description

Copy link
Copy Markdown
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

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

Don't have a m1 machine to verify, just some code level review.

Comment thread test/plugin/run.sh Outdated
parse_commandline "$@"

if [[ $(uname) == 'Darwin' ]] && [[ $(uname -m) == 'arm64' ]]; then
nohup socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock > /dev/null 2>&1 &
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a trap to capture the exit signal and kill this process so when the tests finished this can be released? Otherwise this process is still running even when the tests finished.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From the document, https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/changelog.md

The M1 support has already been added from 0.38.1 and I've run this patch without socat, everything is fine.

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From the document, https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/changelog.md

The M1 support has already been added from 0.38.1 and I've run this patch without socat, everything is fine.

image

What version of mac m1 docker desktop are you using?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I use the newest version of m1 docker desktop, still error if not use socat

[INFO] 
[INFO] --- docker-maven-plugin:0.40.2:build (build) @ tomcat-container ---
./test/plugin/run.sh: line 186: 50210 Killed: 9               ${mvnw} --batch-mode -f ${home}/pom.xml -DskipTests -Dbase_image_java=${base_image_java} -Dbase_image_tomcat=${base_image_tomcat} -Dcontainer_image_version=${container_image_version} clean package

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can you add a trap to capture the exit signal and kill this process so when the tests finished this can be released? Otherwise this process is still running even when the tests finished.

I have removed socat nohup, when the run.sh exit, socat exit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've confirmed with another laptop (13' M2 2022). Previously I've checked on my Mac Studio with M1 Ultra. Still the same results.

$ bash ./test/plugin/run.sh -f spring-4.3.x-scenario

image

I'm using the default configuration with Docker Desktop 4.13.1 (90346),

image

I guess your jvm may not be built for arm64. Anyway, I don't think socat is necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lujiajing1126 Could you submit another PR to bump up the version?
Then I could do another round check locally on my M1 Max.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lujiajing1126 Could you submit another PR to bump up the version? Then I could do another round check locally on my M1 Max.

Sure

@wu-sheng
Copy link
Copy Markdown
Member

I will do local verification on my M1 Max once everything is ready for CI and @kezhenxu94 's review.

@kezhenxu94
Copy link
Copy Markdown
Member

m1 arm64 have to excute

socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock
export DOCKER_HOST=tcp://127.0.0.1:2375

before run

bash ./test/plugin/run.sh -f ${scenario_name}

Can you explain or paste some related links about why the socat command is needed?

https://stackoverflow.com/questions/71300031/docker-image-build-failed-on-mac-m1-chip , the second answer

https://juejin.cn/post/7094919855643557896

https://nxt.engineering/blog/kafka-docker-image/

https://dmp.fabric8.io/ the 3. Global configuration section, DOCKER_HOST description

In the link https://stackoverflow.com/a/71301494/5200161, the other answer suggests switching to fabric8-maven-plugin, dockerfile-maven-plugin from Spotify is inactive for a long time so I think for any reason we should switch to fabric8.

@kezhenxu94
Copy link
Copy Markdown
Member

The changes in this PR is a workaround and not a long-term solution in my opinion.

@kezhenxu94
Copy link
Copy Markdown
Member

kezhenxu94 commented Oct 15, 2022

Or, we can even just use exec maven plugin to execute the Docker command, this has the best compatibility. But we need to extract the existing maven configurations into a Dockerfile. Like https://github.com/apache/dolphinscheduler/blob/cd5fb12e46026f224ed24ad52a6e8711ff212cfe/pom.xml#L436-L466

@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Nov 3, 2022

@zhyyu What is the status of this PR?

Comment thread test/plugin/run.sh Outdated
parse_commandline "$@"

if [[ $(uname) == 'Darwin' ]] && [[ $(uname -m) == 'arm64' ]]; then
nohup socat TCP-LISTEN:2375,range=127.0.0.1/32,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock > /dev/null 2>&1 &
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From the document, https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/changelog.md

The M1 support has already been added from 0.38.1 and I've run this patch without socat, everything is fine.

image

@zhyyu
Copy link
Copy Markdown
Contributor Author

zhyyu commented Nov 4, 2022

On my local m1 mac, If I don't use socat, this error happen.

[INFO] 
[INFO] --- docker-maven-plugin:0.40.2:build (build) @ tomcat-container ---
./test/plugin/run.sh: line 186: 50210 Killed: 9               ${mvnw} --batch-mode -f ${home}/pom.xml -DskipTests -Dbase_image_java=${base_image_java} -Dbase_image_tomcat=${base_image_tomcat} -Dcontainer_image_version=${container_image_version} clean package

@wu-sheng wu-sheng removed this from the 8.13.0 milestone Nov 6, 2022
@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Nov 8, 2022

#379 works.

@wu-sheng wu-sheng closed this Nov 8, 2022
@wu-sheng wu-sheng added this to the 8.14.0 milestone Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Setting enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants