Skip to content

Commit

Permalink
chore(ci): run tests with an older glibc (#800)
Browse files Browse the repository at this point in the history
* chore(ci): test docker images

* try without dind

* put checkout back where it was

* dont duplicate executor names

* install build-essential

* install pkg-config

* chore(ci): test rover's glibc version

* wip: add glibc checker to tests

* wip: only check glibc in CI

* wip: add xenial image to matrix

* try centos image

* try centos:7

* chore(ci): use yum for centos packages

* chore(ci): add -y to yum commands

* chore(ci): fix up bad find and replace

* chore(ci): install cmake for centos

* chore(ci): install gcc instead of cmake

* chore(ci): install openssl on centos

* chore(ci): groupinstall dev tools centos

* chore(ci): use ubuntu for lint

* chore(ci): persist target directory for integration tests

* chore(ci): persist correct directory

* chore(ci): dont persist directory, it's slow

* chore(ci): run unit tests and integration tests on ubuntu

* chore(ci): run e2e tests in the same job
  • Loading branch information
EverlastingBugstopper authored Sep 14, 2021
1 parent dbbb84e commit d97c60c
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 27 deletions.
72 changes: 46 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflows:
name: Lint (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu_gnu_docker]
platform: [ubuntu]
rust_channel: [stable]
command: [lint]
test:
Expand All @@ -23,19 +23,17 @@ workflows:
name: Cargo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu_gnu_docker, ubuntu_musl, macos, windows]
platform: [centos, musl, macos, windows]
rust_channel: [stable]
command: [unit-test]

- xtask:
name: Supergraph demo tests (<< matrix.rust_channel >> rust on << matrix.platform >>)
name: Cargo tests and supergraph demo (<< matrix.rust_channel >> rust on << matrix.platform >>)
matrix:
parameters:
platform: [ubuntu_gnu_vm]
platform: [ubuntu]
rust_channel: [stable]
command: [integration-test]
requires:
- Cargo tests (<< matrix.rust_channel >> rust on ubuntu_gnu_docker)
command: [test]

jobs:
xtask:
Expand All @@ -48,35 +46,28 @@ jobs:
type: executor
command:
type: enum
enum: ["lint", "unit-test", "integration-test"]
enum: ["lint", "unit-test", "integration-test", "test", "dist"]
executor: << parameters.platform >>
steps:
- checkout
- install_system_deps:
platform: << parameters.platform >>
rust_channel: << parameters.rust_channel >>
- exec_xtask:
command: << parameters.command >>
platform: << parameters.platform >>
command: << parameters.command >>

# The machines we use to run our workflows on
executors:
ubuntu_gnu_docker: &ubuntu_gnu_docker_executor
centos: &centos_executor
docker:
- image: cimg/base:stable
- image: centos:7
resource_class: xlarge
environment:
XTASK_TARGET: "x86_64-unknown-linux-gnu"
CHECK_GLIBC: "true"

# This is only used to run supergraph-demo since you can't run Docker from Docker
ubuntu_gnu_vm: &ubuntu_gnu_vm_executor
machine:
image: ubuntu-1604:202104-01
resource_class: xlarge
environment:
XTASK_TARGET: "x86_64-unknown-linux-gnu"

ubuntu_musl: &ubuntu_musl_executor
musl: &musl_executor
docker:
- image: cimg/base:stable
resource_class: xlarge
Expand All @@ -98,6 +89,14 @@ executors:
environment:
XTASK_TARGET: "x86_64-pc-windows-msvc"

# This is only used to run supergraph-demo since you can't run Docker from Docker
ubuntu: &ubuntu_executor
machine:
image: ubuntu-2004:202010-01
resource_class: xlarge
environment:
XTASK_TARGET: "x86_64-unknown-linux-gnu"

# reusable command snippets can be referred to in any `steps` object
commands:
install_system_deps:
Expand All @@ -111,26 +110,47 @@ commands:
- when:
condition:
or:
- equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ]
- equal: [ *ubuntu_gnu_vm_executor, << parameters.platform >> ]
- equal: [ *ubuntu_musl_executor, << parameters.platform >> ]
- equal: [ *ubuntu_executor, << parameters.platform >> ]
- equal: [ *musl_executor, << parameters.platform >> ]
steps:
- run:
name: Update apt repositories
command: sudo apt-get update
- run:
name: Check glibc version
command: ldd --version
- run:
name: Install OpenSSL
command: sudo apt-get install -y libssl-dev

- when:
condition:
equal: [ *ubuntu_musl_executor, << parameters.platform >> ]
equal: [ *centos_executor, << parameters.platform >> ]
steps:
- run:
name: Update and upgrade yum packages
command: yum -y update && yum -y upgrade
- run:
name: Install development tools
command: yum groupinstall -y "Development Tools"
- run:
name: Install gcc and OpenSSL
command: yum -y install gcc openssl-devel
- run:
name: Check glibc version
command: ldd --version

- when:
condition:
equal: [ *musl_executor, << parameters.platform >> ]
steps:
- run:
name: Install musl-tools
command: sudo apt-get install -y musl-tools
- when:
condition:
equal: [ *ubuntu_gnu_docker_executor, << parameters.platform >> ]
or:
- equal: [ *ubuntu_executor, << parameters.platform >> ]
steps:
- node/install:
node-version: "14.17.1"
Expand Down Expand Up @@ -195,7 +215,7 @@ commands:
parameters:
command:
type: enum
enum: [lint, integration-test, unit-test]
enum: [lint, integration-test, unit-test, "test", "dist"]
platform:
type: executor
steps:
Expand Down
67 changes: 67 additions & 0 deletions check_glibc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# This scripts checks if Rover's compiled executable only asks for
# supported versions of glibc

# source: https://gist.github.com/fasterthanlime/17e002a8f5e0f189861c

# usage: ./check_glibc.sh ./target/debug/rover

MAX_VER=2.18

SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
BINARY=$1

# Version comparison function in bash
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}

IFS="
"
VERS=$(objdump -T $BINARY | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -u)

for VER in $VERS; do
vercomp $VER $MAX_VER
COMP=$?
if [[ $COMP -eq 1 ]]; then
echo "Error! ${BINARY} requests GLIBC ${VER}, which is higher than target ${MAX_VER}"
echo "Affected symbols:"
objdump -T $BINARY | grep GLIBC_${VER}
echo "Looking for symbols in libraries..."
for LIBRARY in $(ldd $BINARY | cut -d ' ' -f 3); do
echo $LIBRARY
objdump -T $LIBRARY | fgrep GLIBC_${VER}
done
exit 27
else
echo "Found version ${VER}"
fi
done
20 changes: 19 additions & 1 deletion xtask/src/commands/unit_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use anyhow::Result;
use camino::Utf8PathBuf;
use structopt::StructOpt;

use crate::target::{Target, POSSIBLE_TARGETS};
use crate::tools::CargoRunner;
use crate::tools::{CargoRunner, Runner};
use crate::utils::PKG_PROJECT_ROOT;

use std::{env, str::FromStr};

#[derive(Debug, StructOpt)]
pub struct UnitTest {
Expand All @@ -15,6 +19,20 @@ impl UnitTest {
pub fn run(&self, verbose: bool) -> Result<()> {
let mut cargo_runner = CargoRunner::new(verbose)?;
cargo_runner.test(&self.target)?;

if let Target::GnuLinux = self.target {
if env::var_os("CHECK_GLIBC").is_some() {
let check_glibc_script = "./check_glibc.sh".to_string();
let runner = Runner {
verbose,
tool_name: check_glibc_script.clone(),
tool_exe: Utf8PathBuf::from_str(&check_glibc_script)?,
};
let bin_path = format!("./target/{}/debug/rover", &self.target);
runner.exec(&[&bin_path], &PKG_PROJECT_ROOT, None)?;
}
}

Ok(())
}
}

0 comments on commit d97c60c

Please sign in to comment.