summaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
authorSeth Chisamore <schisamo@chef.io>2016-01-08 18:28:18 -0800
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2016-01-11 16:10:38 -0500
commit602c9fb3d94b76057c58e2a73174789d39495661 (patch)
tree913af53a8ad79ab1ff6dd47e2920a1d8f118c5dd /ci
parent61bd67e56e7917306eedfe13ef8dc7532671c785 (diff)
downloadchef-602c9fb3d94b76057c58e2a73174789d39495661.tar.gz
Move Jenkins verification scripts to top-level
Diffstat (limited to 'ci')
-rw-r--r--ci/jenkins_run_tests.bat14
-rwxr-xr-xci/jenkins_run_tests.sh13
-rwxr-xr-xci/verify-chef.bat56
-rwxr-xr-xci/verify-chef.sh89
4 files changed, 145 insertions, 27 deletions
diff --git a/ci/jenkins_run_tests.bat b/ci/jenkins_run_tests.bat
deleted file mode 100644
index ba9cedd5e2..0000000000
--- a/ci/jenkins_run_tests.bat
+++ /dev/null
@@ -1,14 +0,0 @@
-ruby -v
-
-call bundle check
-
-if %ERRORLEVEL% NEQ 0 (
- call rm Gemfile.lock
- call bundle install --without docgen --path vendor/bundle
-)
-
-bundle exec rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec/functional spec/unit spec/stress spec/integration
-
-set RSPEC_ERRORLVL=%ERRORLEVEL%
-REM Return the error level from rspec
-exit /B %RSPEC_ERRORLVL%
diff --git a/ci/jenkins_run_tests.sh b/ci/jenkins_run_tests.sh
deleted file mode 100755
index 5bf7def062..0000000000
--- a/ci/jenkins_run_tests.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-export PATH=$PATH:/usr/local/bin
-
-ruby -v;
-# remove the Gemfile.lock and try again if bundler fails.
-# This should take care of Gemfile changes that result in "bad" bundles without forcing us to rebundle every time
-bundle install --without docgen --path vendor/bundle || ( rm Gemfile.lock && bundle install --path vendor/bundle )
-bundle exec rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec;
-RSPEC_RETURNCODE=$?
-
-# exit with the result of running rspec
-exit $RSPEC_RETURNCODE
diff --git a/ci/verify-chef.bat b/ci/verify-chef.bat
new file mode 100755
index 0000000000..1c159f0668
--- /dev/null
+++ b/ci/verify-chef.bat
@@ -0,0 +1,56 @@
+
+@ECHO OFF
+
+REM ; %PROJECT_NAME% is set by Jenkins, this allows us to use the same script to verify
+REM ; Chef and Angry Chef
+cd C:\opscode\%PROJECT_NAME%\bin
+
+REM ; We don't want to add the embedded bin dir to the main PATH as this
+REM ; could mask issues in our binstub shebangs.
+SET EMBEDDED_BIN_DIR=C:\opscode\%PROJECT_NAME%\embedded\bin
+
+ECHO.
+
+FOR %%b IN (
+ chef-client
+ knife
+ chef-solo
+ ohai
+) DO (
+
+
+ ECHO Checking for existence of binfile `%%b`...
+
+ IF EXIST %%b (
+ ECHO ...FOUND IT!
+ ) ELSE (
+ GOTO :error
+ )
+ ECHO.
+)
+
+call chef-client --version
+
+REM ; Exercise various packaged tools to validate binstub shebangs
+call %EMBEDDED_BIN_DIR%\ruby --version
+call %EMBEDDED_BIN_DIR%\gem --version
+call %EMBEDDED_BIN_DIR%\bundle --version
+call %EMBEDDED_BIN_DIR%\rspec --version
+
+SET PATH=C:\opscode\%PROJECT_NAME%\bin;C:\opscode\%PROJECT_NAME%\embedded\bin;%PATH%
+
+REM ; Test against the vendored chef gem
+cd C:\opscode\%PROJECT_NAME%\embedded\lib\ruby\gems\2*\gems\chef-*-mingw32
+
+IF NOT EXIST "Gemfile.lock" (
+ ECHO "Chef gem does not contain a Gemfile.lock! This is needed to run any tests."
+ GOTO :error
+)
+
+IF "%PIPELINE_NAME%" == "chef-13" (
+ REM ; Running unit and functional tests
+ call bundle exec rspec -r rspec_junit_formatter -f RspecJunitFormatter -o %WORKSPACE%\test.xml -f documentation spec/unit spec/functional
+) ELSE (
+ REM ; Running unit tests
+ call bundle exec rspec -r rspec_junit_formatter -f RspecJunitFormatter -o %WORKSPACE%\test.xml -f documentation spec/unit spec/functional
+)
diff --git a/ci/verify-chef.sh b/ci/verify-chef.sh
new file mode 100755
index 0000000000..4e60b1fd9f
--- /dev/null
+++ b/ci/verify-chef.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+# $PROJECT_NAME is set by Jenkins, this allows us to use the same script to verify
+# Chef and Angry Chef
+PATH=/opt/$PROJECT_NAME/bin:$PATH
+export PATH
+
+BIN_DIR=/opt/$PROJECT_NAME/bin
+export BIN_DIR
+
+# We don't want to add the embedded bin dir to the main PATH as this
+# could mask issues in our binstub shebangs.
+EMBEDDED_BIN_DIR=/opt/$PROJECT_NAME/embedded/bin
+export EMBEDDED_BIN_DIR
+
+# If we are on Mac our symlinks are located under /usr/local/bin
+# otherwise they are under /usr/bin
+if [ -f /usr/bin/sw_vers ]; then
+ USR_BIN_DIR="/usr/local/bin"
+else
+ USR_BIN_DIR="/usr/bin"
+fi
+export USR_BIN_DIR
+
+# sanity check that we're getting the correct symlinks from the pre-install script
+# solaris doesn't have readlink or test -e. ls -n is different on BSD. proceed with caution.
+if [ ! -L $USR_BIN_DIR/chef-client ] || [ `ls -l $USR_BIN_DIR/chef-client | awk '{print$NF}'` != "$BIN_DIR/chef-client" ]; then
+ echo "$USR_BIN_DIR/chef-client symlink to $BIN_DIR/chef-client was not correctly created by the pre-install script!"
+ exit 1
+fi
+
+if [ ! -L $USR_BIN_DIR/knife ] || [ `ls -l $USR_BIN_DIR/knife | awk '{print$NF}'` != "$BIN_DIR/knife" ]; then
+ echo "$USR_BIN_DIR/knife symlink to $BIN_DIR/knife was not correctly created by the pre-install script!"
+ exit 1
+fi
+
+if [ ! -L $USR_BIN_DIR/chef-solo ] || [ `ls -l $USR_BIN_DIR/chef-solo | awk '{print$NF}'` != "$BIN_DIR/chef-solo" ]; then
+ echo "$USR_BIN_DIR/chef-solo symlink to $BIN_DIR/chef-solo was not correctly created by the pre-install script!"
+ exit 1
+fi
+
+if [ ! -L $USR_BIN_DIR/ohai ] || [ `ls -l $USR_BIN_DIR/ohai | awk '{print$NF}'` != "$BIN_DIR/ohai" ]; then
+ echo "$USR_BIN_DIR/ohai symlink to $BIN_DIR/ohai was not correctly created by the pre-install script!"
+ exit 1
+fi
+
+# Ensure the calling environment (disapproval look Bundler) does not
+# infect our Ruby environment created by the `chef-client` cli.
+for ruby_env_var in _ORIGINAL_GEM_PATH \
+ BUNDLE_BIN_PATH \
+ BUNDLE_GEMFILE \
+ GEM_HOME \
+ GEM_PATH \
+ GEM_ROOT \
+ RUBYLIB \
+ RUBYOPT \
+ RUBY_ENGINE \
+ RUBY_ROOT \
+ RUBY_VERSION
+
+do
+ unset $ruby_env_var
+done
+
+chef-client --version
+
+# Exercise various packaged tools to validate binstub shebangs
+$EMBEDDED_BIN_DIR/ruby --version
+$EMBEDDED_BIN_DIR/gem --version
+$EMBEDDED_BIN_DIR/bundle --version
+$EMBEDDED_BIN_DIR/rspec --version
+
+# ffi-yajl must run in c-extension mode or we take perf hits, so we force it
+# before running rspec so that we don't wind up testing the ffi mode
+FORCE_FFI_YAJL=ext
+export FORCE_FFI_YAJL
+
+PATH=/opt/$PROJECT_NAME/bin:/opt/$PROJECT_NAME/embedded/bin:$PATH
+export PATH
+
+# Test against the vendored Chef gem
+cd /opt/$PROJECT_NAME/embedded/lib/ruby/gems/*/gems/chef-[0-9]*
+
+if [ ! -f "Gemfile.lock" ]; then
+ echo "Chef gem does not contain a Gemfile.lock! This is needed to run any tests."
+ exit 1
+fi
+
+sudo env PATH=$PATH TERM=xterm bundle exec rspec -r rspec_junit_formatter -f RspecJunitFormatter -o $WORKSPACE/test.xml -f documentation spec/functional spec/unit