跳到主要内容

ranger 测试安装 PhantomJS

apache ranger 执行mvn package编译或是测试, 都会报错karma插件问题.

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.1:karma (karma dev) on project security-admin-web: Failed to run task: 'karma start ../../src/test/javascript/karma-dev.conf.js' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

ranger的readme提示要安装PhantomJS依赖, 但其实需要安装的不只readme中写的, 需要安装完整的phantomjs才行.

https://github.com/apache/ranger

Ranger Admin UI tests depend on PhantomJS. If the build fails with npm or Karma errors you can either:

  • install PhantomJS dependencies for your platform (bzip2 and fontconfig)
  • skip JavaScript test execution: mvn -DskipJSTests ...
ubuntu@7c74ad7d922c:~$ sudo ln -sf /home/coder/$PHANTOM_JS/bin/phantomjs  /usr/local/bin
ubuntu@7c74ad7d922c:~$ phantomjs --version
1.9.8

安装完成后, mvn test编译测试终于通过了

 mvn test -pl security-admin  -Dtest=TestXUserREST#test99deleteUsersByUserName

update, phantomjs还是没启动成功, web页面相关测试未通过, 还是得跳过js测试才行.

mvn test -pl security-admin  -Dtest=TestXUserREST#test99deleteUsersByUserName -DskipJSTests

update, 修改/etc/ssl/openssl.cnf 可以成功运行

https://github.com/ariya/phantomjs/issues/15449

Just Uncomment the following line putting in /etc/ssl/openssl.cnf

[default_conf]
#ssl_conf = ssl_sect

解决了下面的报错

[INFO] 12 07 2023 17:30:32.231:INFO [launcher]: Trying to start PhantomJS again (1/2).
[INFO] 12 07 2023 17:30:32.256:ERROR [phantomjs.launcher]: Auto configuration failed
[INFO]
[INFO] 12 07 2023 17:30:32.257:ERROR [phantomjs.launcher]: 139939778922432:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
[INFO]
[INFO] 12 07 2023 17:30:32.258:ERROR [phantomjs.launcher]: 139939778922432:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
[INFO]
[INFO] 12 07 2023 17:30:32.259:ERROR [phantomjs.launcher]: 139939778922432:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
[INFO]
[INFO] 12 07 2023 17:30:32.260:ERROR [phantomjs.launcher]: 139939778922432:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
[INFO]
[INFO] 12 07 2023 17:30:32.264:ERROR [launcher]: Cannot start PhantomJS

How to install PhantomJS on Ubuntu

https://gist.github.com/julionc/7476620

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev

Install these packages needed by PhantomJS to work correctly.

sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev

Get it from the PhantomJS website.

cd ~
export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

Once downloaded, move Phantomjs folder to /usr/local/share/ and create a symlink:

sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

Now, It should have PhantomJS properly on your system.

phantomjs --version
  • install_phantomjs.sh
#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#

if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi

PHANTOM_VERSION="phantomjs-1.9.8"
ARCH=$(uname -m)

if ! [ $ARCH = "x86_64" ]; then
$ARCH="i686"
fi

PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev -y
sudo apt-get install libfreetype6 libfreetype6-dev -y
sudo apt-get install libfontconfig1 libfontconfig1-dev -y

cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin