1 #!/bin/sh 2 3 set -eux 4 5 6 7 # create user account for logging in 8 9 if ! id admin 2>/dev/null; then 10 11 useradd admin -G wheel 12 13 echo admin:foobar | chpasswd 14 15 fi 16 17 18 19 # mock compose creation calls to backend for testing purposes 20 21 sed -i "s|"/api/v0/compose"|"/api/v0/compose?test=2"|" /usr/share/cockpit/welder/main.js 22 23 24 25 # disable https in cockpit and use http instead 26 27 printf "[WebService]\nAllowUnencrypted=true\n" > /etc/cockpit/cockpit.conf 28 29 30 31 # Make cockpit.socket and lorax-composer start 32 33 systemctl start cockpit.socket 34 35 systemctl start lorax-composer 36 37 38 39 # Make selenium hub and node-firefox or node-chrome ready to use 40 41 TICKS=120 42 43 44 45 wait_curl(){ 46 47 LINK=$1 48 49 GREP_CMD=$2 50 51 FOUND="" 52 53 FULLLINK="http://127.0.0.1:4444$LINK" 54 55 for _ in $(seq $TICKS); do 56 57 if curl -s --connect-timeout 1 "$FULLLINK" | grep "$GREP_CMD" >/dev/null; then 58 59 echo "$FULLLINK ('$GREP_CMD' available on page)" >&2 60 61 FOUND="yes" 62 63 break 64 65 else 66 67 sleep 0.5 68 69 fi 70 71 done 72 73 if [ -z "$FOUND" ]; then 74 75 echo "ERROR: $FULLLINK ('$GREP_CMD' not available)" >&2 76 77 return 1 78 79 fi 80 81 } 82 83 84 85 # pull selenium container image from docker hub directly 86 87 podman pull -q --tls-verify=false docker.io/selenium/hub:3 88 89 podman pull -q --tls-verify=false "docker.io/selenium/node-$BROWSER:3" 90 91 92 93 # clear selenium containers 94 95 # sometimes podman rm -f does not work, work around is stop container first then remove it 96 97 podman ps -qa -f 'ancestor=selenium' | xargs --no-run-if-empty podman stop 98 99 podman ps -qa -f 'ancestor=selenium' | xargs --no-run-if-empty podman rm -f 100 101 102 103 podman run -d --network host --name selenium-hub selenium/hub:3 104 105 wait_curl /grid/console "Grid Console" 106 107 podman run -d --shm-size=512M --name "$BROWSER" --network host -e HUB_HOST=127.0.0.1 -e HUB_PORT=4444 "selenium/node-$BROWSER:3" 108 109 wait_curl /grid/console "browserName: $BROWSER" 110 111 112 113 # check out current rhel-8.0 branch to get the tests; they are not shipped in the tarball 114 115 if [ -d welder-web ]; then rm -rf welder-web; fi 116 117 git clone -b rhel-8.0 https://github.com/weldr/welder-web.git 118 119 120 121 # test provision 122 123 cd welder-web/test/end-to-end 124 125 npm install 126 127 128 129 # wait for lorax-composer initialization before running test 130 131 until curl --unix-socket /run/weldr/api.socket 132 133 http://localhost:4000/api/status | grep '"db_supported": *true'; do 134 135 sleep 1; 136 137 done; 138 139 140 141 # run end to end test 142 143 COCKPIT_USERNAME=admin COCKPIT_PASSWORD=foobar npm run test