Skip to content

NH-27837: add aarch64 support #20

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

Merged
merged 17 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/docker-arm-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build docker images for arm

on:
# push:
# paths:
# - 'test/run_tests/Dockerfile_*'
# Allows running this workflow manually from the Actions tab
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/apm_ruby
DOCKERFILE: test/run_tests/Dockerfile

jobs:

build_push:
name: Build docker images for arm
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
os: [ubuntu_arm]

steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_${{ matrix.os }} # e.g. apm_ruby_ubuntu
flavor: |
latest=true

- name: Build and push Docker image ARM
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64
push: true
file: test/run_tests/Dockerfile_${{ matrix.os }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


39 changes: 36 additions & 3 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build docker images
on:
push:
paths:
- 'test/run_tests/Dockerfile_*'
- 'test/run_tests/Dockerfile_*'
# Allows running this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -27,6 +27,12 @@ jobs:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container Registry
uses: docker/login-action@v2
with:
Expand All @@ -38,7 +44,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_${{ matrix.os }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_${{ matrix.os }} # e.g. apm_ruby_ubuntu
flavor: |
latest=true

Expand All @@ -47,7 +53,34 @@ jobs:
with:
context: .
push: true
platforms: linux/amd64
file: test/run_tests/Dockerfile_${{ matrix.os }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}


# build arm image as well
- name: Extract metadata (tags, labels) for Docker (ARM)
id: meta_arm
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_${{ matrix.os }}_arm # e.g. apm_ruby_ubuntu_arm
flavor: |
latest=true

- name: Build and push Docker image (ARM)
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64
push: true
file: test/run_tests/Dockerfile_${{ matrix.os }}_arm
tags: ${{ steps.meta_arm.outputs.tags }}
labels: ${{ steps.meta_arm.outputs.labels }}








8 changes: 7 additions & 1 deletion .github/workflows/test_on_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ jobs:
fail-fast: false
matrix:
ruby: ['3.1', '3.0', '2.7', '2.6']
os: [ubuntu, ubuntu_arm]
exclude:
- os: ubuntu_arm
ruby: '2.7'
- os: ubuntu_arm
ruby: '2.6'

container:
image: ghcr.io/${{ github.repository }}/apm_ruby_ubuntu
image: ghcr.io/${{ github.repository }}/apm_ruby_${{ matrix.os }}

env:
SW_APM_GEM_TEST: true
Expand Down
113 changes: 113 additions & 0 deletions .github/workflows/test_on_ubuntu_arm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Copyright (c) 2021 SolarWinds, LLC.
# All rights reserved.

name: Run Ruby Tests on ARM Ubuntu (Push Event)

on:
push:
branches-ignore:
- main
paths-ignore:
- 'test/run_tests/Dockerfile_*'
workflow_dispatch:

jobs:

ubuntu_test:
name: ubuntu arm - ruby ${{ matrix.ruby }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby: ['3.1', '3.0']

container:
image: ghcr.io/${{ github.repository }}/apm_ruby_ubuntu_arm

env:
SW_APM_GEM_TEST: true
SW_APM_REPORTER: file
SW_APM_COLLECTOR: /tmp/sw_apm_traces.bson
SW_APM_REPORTER_FILE_SINGLE: false
OBOE_STAGING: true
MONGO_SERVER: "mongo"
RABBITMQ_SERVER: "rabbitmq"
MEMCACHED_SERVER: "memcached"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_ROOT_PASSWORD: "admin"
MYSQL_HOST: "mysql"
MYSQL_DATABASE: "test_db"
POSTGRES_DB: "test_db"
DOCKER_MYSQL_PASS: "admin"
DOCKER_PSQL_PASS: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_HOST: "postgres"
QUERY_LOG_FILE: "/tmp/sw_apm_query_logs.txt"
REDIS_PASSWORD: "redis_pass"
TEST_RUNS_TO_FILE: "true"

services:
memcached:
image: memcached:latest
ports:
- 11211:11211
options: --health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'" --health-interval 10s --health-timeout 5s --health-retries 5
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672
options: --health-cmd "rabbitmqctl node_health_check" --health-interval 10s --health-timeout 5s --health-retries 5
mongo:
image: mongo:6
ports:
- 27017:27017
options: --health-cmd "mongosh --quiet --eval 'quit(db.runCommand({ping:1}).ok ? 0:2)'" --health-interval 10s --health-timeout 5s --health-retries 5
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: test_db
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mysql:
image: mariadb:latest
env:
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: test_db
MYSQL_ROOT_PASSWORD: admin
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
# may need --default-authentication-plugin=mysql_native_password

steps:
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: print some info
run: |
user=`whoami`
pwd=`pwd`
system=`uname -m`
echo "User: $user"
echo "Current dir: $pwd"
echo "Home dir: $HOME"
echo "System: $system"
echo "Branch: ${GITHUB_REF#refs/*/}"

- name: ruby tests
run: |
export HOME=/root
export PUSH_EVENT=REGULAR_PUSH
test/run_tests/ruby_setup.sh
version=`rbenv versions --bare | grep ${{ matrix.ruby }}`
rbenv global $version
echo "testing with ruby version: $version"
test/run_tests/run_tests.sh -r $version
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ redis-test.*

# mac DS_Store
.DS_Store

# Docker container image
test/run_tests/.ruby_version_alpine
test/run_tests/.ruby_version_alpine
test/run_tests/.ruby_version_debian
test/run_tests/.ruby_version_ubuntu


28 changes: 21 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ Rake::TestTask.new do |t|
when /libraries/
t.test_files = FileList['test/support/*_test.rb'] +
FileList['test/reporter/*_test.rb'] +
FileList['test/instrumentation/*_test.rb']
((ENV["ARCH"] != "aarch64" && ENV["ARCH"] != "arm64")?
FileList['test/instrumentation/*_test.rb'] :
FileList['test/instrumentation/*_test.rb'].exclude("test/instrumentation/memcached_test.rb", "test/instrumentation/grpc_test.rb"))

when /instrumentation_mocked/
# WebMock is interfering with other tests, so these have to run separately
t.test_files = FileList['test/mocked/*_test.rb']
Expand Down Expand Up @@ -68,15 +71,22 @@ end

task :docker_test => :docker_tests

desc 'Start docker container for testing and debugging, accepts: alpine, debian, centos as args, default: ubuntu'
desc 'Start docker container for testing and debugging, accepts: alpine, debian, centos as args, default: ubuntu
Example: bundle exec rake docker ubuntu arm'
task :docker, :environment do
_arg1, arg2 = ARGV
_arg1, arg2, arg3 = ARGV
os = arg2 || 'ubuntu'
arch = arg3 || ''

puts "Running on #{os}"

Dir.chdir('test/run_tests')
exec("docker-compose down -v --remove-orphans && docker-compose run --service-ports --name ruby_sw_apm_#{os} ruby_sw_apm_#{os} /code/ruby-solarwinds/test/run_tests/ruby_setup.sh bash")
case arg3
when "arm"
exec("docker-compose -f docker-compose-arm.yml down -v --remove-orphans && docker-compose -f docker-compose-arm.yml run --service-ports --name ruby_sw_apm_#{os}_arm ruby_sw_apm_#{os}_arm /code/ruby-solarwinds/test/run_tests/ruby_setup.sh bash")
else
exec("docker-compose down -v --remove-orphans && docker-compose run --service-ports --name ruby_sw_apm_#{os} ruby_sw_apm_#{os} /code/ruby-solarwinds/test/run_tests/ruby_setup.sh bash")
end
end

desc 'Stop all containers that were started for testing and debugging'
Expand Down Expand Up @@ -157,8 +167,10 @@ task :fetch_oboe_file_from_staging do
end

unless ENV['OBOE_LOCAL']
sha_files = ['liboboe-1.0-alpine-x86_64.so.0.0.0.sha256',
'liboboe-1.0-x86_64.so.0.0.0.sha256']
sha_files = ['liboboe-1.0-alpine-x86_64.so.0.0.0.sha256',
'liboboe-1.0-x86_64.so.0.0.0.sha256',
'liboboe-1.0-aarch64.so.0.0.0.sha256',
'liboboe-1.0-alpine-aarch64.so.0.0.0.sha256']

sha_files.each do |filename|
remote_file = File.join(oboe_stg_dir, filename)
Expand Down Expand Up @@ -244,7 +256,9 @@ task :fetch_oboe_file_from_prod do
end

sha_files = ['liboboe-1.0-alpine-x86_64.so.0.0.0.sha256',
'liboboe-1.0-x86_64.so.0.0.0.sha256']
'liboboe-1.0-x86_64.so.0.0.0.sha256',
'liboboe-1.0-aarch64.so.0.0.0.sha256',
'liboboe-1.0-alpine-aarch64.so.0.0.0.sha256' ]

sha_files.each do |filename|
remote_file = File.join(files_solarwinds, filename)
Expand Down
16 changes: 12 additions & 4 deletions ext/oboe_metal/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@
ao_path = File.join('https://agent-binaries.cloud.solarwinds.com/apm/c-lib/', version)
end

ao_arch = 'x86_64'
ao_arch = "x86_64"
system_arch = `uname -m` # for mac, the command is `uname` # "Darwin\n"; try `uname -a`
case system_arch.gsub("\n","")
when "x86_64"
ao_arch = "x86_64"
when "aarch64"
ao_arch = "aarch64"
end

if File.exist?('/etc/alpine-release')
version = File.read('/etc/alpine-release').strip

tmp_ao_arch = ao_arch.clone
ao_arch =
if Gem::Version.new(version) < Gem::Version.new('3.9')
'alpine-libressl-x86_64'
"alpine-libressl-#{tmp_ao_arch}"
else # openssl
'alpine-x86_64'
"alpine-#{tmp_ao_arch}"
end
end

Expand Down
16 changes: 9 additions & 7 deletions gemfiles/libraries.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ gem 'rest-client'
# doesn't install well on alpine, explained here:
# https://qiita.com/takkeybook/items/5eae085d902957f0fe5b
# needs fixing for Ruby >= 3
if File.exist?('/etc/centos-release') && RUBY_VERSION < '2.6.0'
gem 'grpc', '~> 1.48.0'
gem 'google-protobuf'
elsif !File.exist?('/etc/alpine-release') && RUBY_VERSION < '3.0.0'
gem 'grpc'
gem 'google-protobuf'
if ENV["ARCH"] != "aarch64" && ENV["ARCH"] != "arm64"
if File.exist?('/etc/centos-release') && RUBY_VERSION < '2.6.0'
gem 'grpc', '~> 1.48.0'
gem 'google-protobuf'
elsif !File.exist?('/etc/alpine-release') && RUBY_VERSION < '3.0.0'
gem 'grpc'
gem 'google-protobuf'
end
end

gem 'bunny'
Expand All @@ -38,7 +40,7 @@ end
gem 'httpclient'
gem 'logging'
gem 'lumberjack'
gem 'memcached'
gem 'memcached' if ENV["ARCH"] != 'aarch64' && ENV["ARCH"] != "arm64"
gem 'mongo', '>= 2.11.3'
gem 'patron' # not instrumented, included to test a non-instrumented faraday adapter
gem 'redis', '<= 4.8.0'
Expand Down
Loading