Launch chrome browser inside a circleci machine for testing by Selenium

Hi,

I am trying to launch several Selenium tests through your circleci. As I am using webdriver for chrome, the GUI browser is launched to verify all use cases.

The thing is, if I connect by ssh rebuild option, everything works but in an usual job don’t.

My app is deployed in K8S and I get the kubectl get svc in order to get the IP and then launch the “baremetal” Selenium tests. The Selenium tests are not containerized because I think is not necessary if I can launch in a circleci machine instead a docker. But the behaviour is the described below.

The job is decribed as follow:

componenttests:
machine:
image: circleci/classic:201808-01
environment:
K8S_VERSION: v1.10.0
KUBECONFIG: /home/circleci/.kube/config
MINIKUBE_VERSION: v0.30.0
MINIKUBE_WANTUPDATENOTIFICATION: false
MINIKUBE_WANTREPORTERRORPROMPT: false
MINIKUBE_HOME: /home/circleci
CHANGE_MINIKUBE_NONE_USER: true
steps:
- checkout
- run:
name: setup kubectl
command: |
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/{K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ mkdir -p {HOME}/.kube
touch {HOME}/.kube/config - run: name: setup minikube command: | curl -Lo minikube - run: name: setup helm command: curl - run: name: start minikube command: | sudo -E minikube start --vm-driver=none --cpus 2 --memory 2048 --kubernetes-version={K8S_VERSION} &> $HOME/minikube.log 2>&1 < /dev/null
- run:
name: wait for minikube
command: |
JSONPATH=’{range .items[]}{@.metadata.name}:{range @.status.conditions[]}{@.type}={@.status};{end}{end}’;
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q “Ready=True”; do
sleep 1;
done
- run:
name: fix RBAC
command: |
# make default account cluster-admin
kubectl create clusterrolebinding add-on-cluster-admin --clusterrole cluster-admin --serviceaccount=kube-system:default
- run:
name: dump cluster-info
command: |
kubectl cluster-info
kubectl get po --all-namespaces
- run:
name: install helm in cluster
command: |
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --wait --service-account tiller
- run:
name: launch component tests
shell: /bin/bash --login
command: |
export DISPLAY=:99
cat /etc/os-release
pwd
uname
whoami
ls -lrt
- run:
name: install browser
shell: /bin/bash --login
command: |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i --force-depends google-chrome-stable_current_amd64.deb
sudo apt-get install -f
- run:
name: install drivers
shell: /bin/bash --login
command: |
wget
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/
- run:
name: atoperural deployment
shell: /bin/bash --login
command: |
docker build -t jpastorr/atoperural:latest . -f docker/Dockerfile.atoperural
docker build -t jpastorr/atoperural-db:latest docker -f docker/Dockerfile.mysql
helm install helm/atoperural -n atoperural --set volume.enabled=false

  - run:
      name: launch component test
      shell: /bin/bash
      command: |
         ps $$
         whoami
         sudo apt install -y xvfb
         url=`kubectl get svc | grep 'atoperural ' | tr -s ' ' | cut -d' ' -f 3`
         mvn -f ct -Datoperural=${url} test

Any idea, help?

Thanks in advance.