tag:blogger.com,1999:blog-167583012024-03-13T19:11:41.716+01:00Jan Kester BlogJan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.comBlogger42125tag:blogger.com,1999:blog-16758301.post-4767139723897940972023-12-30T13:25:00.005+01:002023-12-30T13:25:41.093+01:00Push image to Docker https registry<h1 style="text-align: left;"> Setup remote https registry</h1><div style="text-align: left;"><div style="margin-left: 40px; text-align: left;"><span style="font-family: courier; font-size: x-small;">docker container stop registry</span><br /><span style="font-family: courier; font-size: x-small;">docker container rm -v registry</span><br /><span style="font-family: courier; font-size: x-small;">ls /var/lib/</span><br /><span style="font-family: courier; font-size: x-small;">cd</span><br /><span style="font-family: courier; font-size: x-small;">mkdir certs</span><br /><span style="font-family: courier; font-size: x-small;">cd certs</span><br /><span style="font-family: courier; font-size: x-small;">openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -addext "subjectAltName = DNS:myregistry.jankester.com" -x509 -days 365 -out certs/domain.crt</span><br /><span style="font-family: courier; font-size: x-small;">cd ..</span><br /><span style="font-family: courier; font-size: x-small;">openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -addext "subjectAltName = DNS:myregistry.jankester.com" -x509 -days 365 -out certs/domain.crt</span><br /><span style="font-family: courier; font-size: x-small;">ls -ltr</span><br /><span style="font-family: courier; font-size: x-small;">ls</span><br /><span style="font-family: courier; font-size: x-small;">cd certificate_authority</span><br /><span style="font-family: courier; font-size: x-small;">history | grep import</span><br /><span style="font-family: courier; font-size: x-small;">ls -ltr ../</span><br /><span style="font-family: courier; font-size: x-small;">ls -ltr ../certs</span><br /><span style="font-family: courier; font-size: x-small;">cd</span><br /><span style="font-family: courier; font-size: x-small;">docker run -d --restart=always --name registry -v "$(pwd)"/certs:/certs -e REGISTRY_HTTP_ADDR=0.0.0.0:5443 -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key -p 5443:5443 registry:2</span><br /><span style="font-family: courier; font-size: x-small;">docker container ls</span><br /><span style="font-family: courier; font-size: x-small;">history | grep allow</span><br /><span style="font-family: courier; font-size: x-small;">sudo ufw allow 5443</span><br /><span style="font-family: courier; font-size: x-small;">docker images ls</span><br /><span style="font-family: courier; font-size: x-small;">curl -X GET http://localhost:5000/v2/_catalogs</span><br /><span style="font-family: courier; font-size: x-small;">curl -X GET https://localhost:443/v2/_catalogs</span><br /><span style="font-family: courier; font-size: x-small;">curl -X GET https://localhost:5443/v2/_catalogs</span><br /><span style="font-family: courier; font-size: x-small;">curl -X GET -k https://localhost:5443/v2/_catalogs</span><br /><span style="font-family: courier; font-size: x-small;">ping myregistry.jankester.com</span><br /><br /></div><br /></div><p><br /></p><h1 style="text-align: left;">Push image</h1><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;"><span style="font-size: x-small;">docker pull hello-world</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">docker tag hello-world:latest myregistry.jankester.com:5443/my-hello-world</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">docker push myregistry.jankester.com:5443/my-hello-world</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">curl -X GET -k https://localhost:5443/v2/_catalog</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd source</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd microservices-in-dotnet-book-second-edition/</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd Chapter03/</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls -lt</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">vi shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">history | grep apply</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl apply -f shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl delete all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl delete pod/shopping-cart-7dbc5f55b-vv2wv pod/shopping-cart-d6c9bd467-wr5xz service/kubernetes service/shopping-cart deployment.apps/shopping-cart replicaset.apps/shopping-cart-7dbc5f55b replicaset.apps/shopping-cart-d6c9bd467</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl apply -f shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cat shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls -ltr</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">vi shopping-cart.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">vi shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">sudo apt-get base64</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">sudo apt-get install base64</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget localhost:8080</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget localhost:8080/shopping-cart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget localhost:8080/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">man wget</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget -O - localhost:8080/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget -O localhost:8080/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget -o localhost:8080/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">curl localhost:8080/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">curl -X POST http://localhost:8080/shoppingcart/123/items -H "Content-Type: application/json" -d '[1,2]'</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">curl localhost:8080/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl -n kube-system describe secret default</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd source/microservices-in-dotnet-book-second-edition/Chapter03/</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">vi shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls -ltr</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl apply -f shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ping www.jankester.com</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">vi shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl apply -f shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget localhost:5001</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget 192.55.14.78:5001</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget 192.55.14.78:5001/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">netstat -an | grep -w LISTEN</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">wget http://192.55.14.78:5001/shoppingcart/123</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">vi shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl apply -f shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">vi shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cat shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl port-forward shopping-cart 80:8080</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl port-forward pod/shopping-cart-d6c9bd467-2qxmf 80:8080</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl port-forward pod/shopping-cart-d6c9bd467-2qxmf 8080:80</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls -ltr</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd certificate_authority</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls pki/</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls pki/private/</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd cert</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd certs/</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cat domain.crt</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">sudo cp domain.crt /usr/local/share/ca-certificates/domain.crt</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">sudo update-ca-certficates</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">sudo update-ca-certificates</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">microk8s stop</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">microk8s start</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl delete pod/shopping-cart-d6c9bd467-lnqp7</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">history | grep mic</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">cd source/microservices-in-dotnet-book-second-edition/Chapter03/</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">ls</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl apply -f shopping-cart-local.yaml</span></span><br /><span style="font-family: courier;"><span style="font-size: x-small;">kubectl get all</span></span><br /></p><p style="text-align: left;"> </p><p><br /></p><h1 style="text-align: left;">Test kubectl<br /></h1><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier; font-size: x-small;">wget http://localhost:5001/v2/search?</span><br /><span style="font-family: courier; font-size: x-small;">curl -X GET -k https://localhost:5443/v2/_catalog</span><br /><span style="font-family: courier; font-size: x-small;">history | grep curl</span><br /><span style="font-family: courier; font-size: x-small;">curl -X POST http://localhost:5000/shoppingcart/123/items -H "Content-Type: application/json" -d '[5,15,29]'</span><br /><span style="font-family: courier; font-size: x-small;">curl -X POST http://localhost:5001/shoppingcart/123/items -H "Content-Type: application/json" -d '[5,15,29]'</span><br /><span style="font-family: courier; font-size: x-small;">kubectl get all</span><br /><span style="font-family: courier; font-size: x-small;">cat shopping-cart-local.yaml</span><br /><span style="font-family: courier; font-size: x-small;">view shopping-cart-local.yaml</span><br /><span style="font-family: courier; font-size: x-small;">netstat -an | grep -w LISTEN</span><br /><span style="font-family: courier; font-size: x-small;">kubectl get all</span><br /><span style="font-family: courier; font-size: x-small;">kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/</span><br /><span style="font-family: courier; font-size: x-small;">kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml</span><br /><span style="font-family: courier; font-size: x-small;">kubectl proxy</span><br /><span style="font-family: courier; font-size: x-small;">microk8s stop</span><br /></p><p><br /></p>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-1980869142180905932023-12-30T13:18:00.000+01:002023-12-30T13:18:05.522+01:00Certbot https certificate<h1 style="text-align: left;"> Install https certificate for apache</h1><div style="margin-left: 40px; text-align: left;"><span style="font-family: courier; font-size: x-small;">sudo apt install certbot python3-certbot-apache<br />cd /etc/apache2/sites-available/<br />ls<br />sudo cp 000-default.conf jankester-com.conf<br />sudo vi jankester-com.conf<br />sudo a2ensite jankester-com.conf<br />sudo a2dissite 000-default.conf<br />sudo apache2ctl configtest<br />cd /var/www/<br />ls<br />ls -l<br />sudo mkdir jankester-com<br />sudo mkdir jankester-com/public_html<br />sudo cp html/* jankester-com/public_html/.<br />sudo apache2ctl configtest<br />sudo systemctl restart apache2<br />sudo ufw status<br />sudo certbot --apache<br />sudo apt-get install certbot python-certbot-apache<br />sudo apt-get install certbot python3-certbot-apache<br />sudo certbot --apache<br />sudo apt install certbot python3-certbot-apache<br />certbot --version<br />sudo apt install snapd<br />sudo snap install --classic certbot<br />/snap/bin/certbot --version<br />sudo /snap/bin/certbot --apache<br />cd jankester-com/public_html/</span><br /></div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-72880724745682471602023-12-30T13:15:00.003+01:002023-12-30T13:15:24.872+01:00Install tileserver<h1 style="text-align: left;"><span style="font-family: verdana;">Install Postgis </span></h1><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;">sudo apt-get install -y postgresql postgis<br /><br />sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts<br /><br />sudo service postgresql start<br /><br />locale<br /><br />git --version # to verify whether git is already installed<br /><br />sudo apt-get install -y git</span></p><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;">sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts<br /><br />sudo service postgresql start<br /><br />echo $USER<br /><br />locale -c<br /><br />locale<br /><br />createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0<br /><br />sudo -u postgres createuser -s $USER<br /><br />createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0<br /><br />psql -d gis -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;'<br /><br />psql -d gis -c "create user jan;grant all privileges on database gis to postgres;"<br /><br />psql -d gis -c "grant all privileges on database gis to postgres;"<br /><br />psql -d gis -c 'create user "www-data";grant all privileges on database gis to "www-data";'<br /><br />psql -d gis -c 'ALTER TABLE geometry_columns OWNER TO postgres;'<br /><br />psql -d gis -c 'ALTER TABLE spatial_ref_sys OWNER TO postgres;'<br /><br />sudo vi /etc/postgresql/*/main/pg_hba.conf<br /><br />history<br /><br />wget https://ipinfo.io/ip -qO -<br /><br />sudo vi /etc/postgresql/*/main/pg_hba.conf<br /><br />sudo vi /etc/postgresql/*/main/postgresql.conf<br /><br />sudo /etc/init.d/postgresql restart<br /><br />psql -U postgres -h $HOSTNAME -c "\l+"<br /><br />sudo su - postgres psql -U postgres -h $HOSTNAME -c "\l+"<br /><br />sudo su - postgres<br /><br />sudo -u postgres psql<br /><br />sudo vi /etc/postgresql/*/main/pg_hba.conf<br /><br />sudo /etc/init.d/postgresql restart<br /><br />psql -U postgres<br /><br /></span> </p><h1 style="text-align: left;"><span style="font-family: verdana;">Install Apache </span><br /></h1><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;">lsb_release -a<br /><br />sudo apt install apache2<br /><br />sudo ufw app list<br /><br />sudo ufw allow 'Apache'<br /><br />sudo ufw allow 'Apache Secure'<br /><br />sudo ufw app list<br /><br />sudo ufw status<br /><br />sudo systemctl status apache2<br /><br />hostname -I</span></p><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;"> </span></p><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;">sudo apt-get install -y apache2 apache2-dev<br /><br />sudo service apache2 status<br /><br />sudo vi /etc/apache2/apache2.conf<br /><br />sudo service apache2 reload<br /><br />curl localhost| grep 'It works!' </span><span style="font-family: courier;"><br /></span></p><p> </p><h1 style="text-align: left;"><span style="font-family: verdana;">Setup Mapnik </span></h1><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;"><span style="font-size: x-small;"> sudo apt-get -y install ca-certificates gnupg curl unzip gdal-bin tar
wget bzip2 build-essential clang python3-psycopg2 python3-yaml
python3-requests postgresql-client<br /><br />sudo apt-get -y install munin-node munin protobuf-c-compiler libtiff5-dev<br /><br />swapon -s<br /><br />free -h<br /><br />sudo fallocate -l 2G /swapfile<br /><br />sudo chmod 600 /swapfile<br /><br />sudo mkswap /swapfile<br /><br />sudo swapon /swapfile<br /><br />swapon -s<br /><br />free -h<br /><br />sudo
apt-get install -y git autoconf libtool libxml2-dev libbz2-dev
libgeos-dev libgeos++-dev libproj-dev gdal-bin libgdal-dev g++
libmapnik-dev mapnik-utils python3-mapnik<br /><br />ls<br /><br />mapnik-config -v<br /><br />mapnik-config --input-plugins<br /><br />python3 -c "import mapnik;print(mapnik.__file__)"<br /><br />sudo apt-get install -y python-setuptools python3-setuptools<br /><br /><br />wget https://ipinfo.io/ip -qO -<br /><br />sudo add-apt-repository -y ppa:osmadmins/ppa<br /><br />sudo apt-get update<br /><br />sudo apt-get install -y libapache2-mod-tile # this includes both mod-tile and renderd<br /><br />sudo apt-get install -y python3 python3-distutils<br /><br /># Verify Python installation:<br /><br />python -V<br /><br />python3 -V<br /><br />sudo apt-get install -y python3 python3-distutils python<br /><br />python -V<br /><br />sudo apt-get install -y python-yaml<br /><br />pip -V # to verify whether pip is already installed<br /><br />sudo apt-get install -y python3-pip<br /><br />python3 -m pip install --upgrade pip<br /><br />sudo python3 -m pip install --upgrade pip<br /><br />sudo apt-get install -y mapnik-utils<br /><br />cd<br /><br />mkdir -p ~/src<br /><br />cd ~/src</span></span></p><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;"> </span></p><p> </p><h1 style="text-align: left;"><span style="font-family: verdana;">Openstreetmap Carto</span></h1><p style="text-align: left;"><span style="font-family: verdana;"> Create style</span></p><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;"><span style="font-size: x-small;">git clone https://github.com/gravitystorm/openstreetmap-carto.git<br /><br />cd openstreetmap-carto<br /><br />sudo apt-get install -y fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted fonts-hanazono ttf-unifont<br /><br />cd ~/src<br /><br />git clone https://github.com/googlefonts/noto-emoji.git<br /><br />git clone https://github.com/googlefonts/noto-fonts.git<br /><br />sudo cp noto-emoji/fonts/NotoColorEmoji.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-emoji/fonts/NotoEmoji-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansArabicUI/NotoSansArabicUI-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoNaskhArabicUI/NotoNaskhArabicUI-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansArabicUI/NotoSansArabicUI-Bold.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoNaskhArabicUI/NotoNaskhArabicUI-Bold.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansAdlam/NotoSansAdlam-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansAdlamUnjoined/NotoSansAdlamUnjoined-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansChakma/NotoSansChakma-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansOsage/NotoSansOsage-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansSinhalaUI/NotoSansSinhalaUI-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansArabicUI/NotoSansArabicUI-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansCherokee/NotoSansCherokee-Bold.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansSinhalaUI/NotoSansSinhalaUI-Bold.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansSymbols/NotoSansSymbols-Bold.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansArabicUI/NotoSansArabicUI-Bold.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/unhinted/ttf/NotoSansSymbols2/NotoSansSymbols2-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/hinted/ttf/NotoSansBalinese/NotoSansBalinese-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />sudo cp noto-fonts/archive/hinted/NotoSansSyriac/NotoSansSyriac-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />mkdir NotoSansSyriacEastern-unhinted<br /><br />cd NotoSansSyriacEastern-unhinted<br /><br />wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSansSyriacEastern-unhinted.zip<br /><br />unzip NotoSansSyriacEastern-unhinted.zip<br /><br />sudo cp NotoSansSyriacEastern-Regular.ttf /usr/share/fonts/truetype/noto<br /><br />cd ..<br /><br />sudo apt install fontconfig<br /><br />sudo apt autoremove<br /><br />sudo fc-cache -fv<br /><br />fc-list<br /><br />fc-list | grep Emoji<br /><br />sudo apt-get install -y fonts-dejavu-core<br /><br />node -v<br /><br />curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - &&\<br /><br />cd ..<br /><br />curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - &&sudo apt-get install -y nodejs<br /><br />node -v<br /><br />nodejs -v<br /><br />npm -v<br /><br />sudo apt install nodejs<br /><br />nodejs -v<br /><br />sudo apt-get -y nodejs<br /><br />sudo apt-get install -y nodejs<br /><br />node -v 2>/dev/null || sudo ln -fs /usr/bin/nodejs /usr/local/bin/node<br /><br />nodejs -v<br /><br />ls /usr/local/bin/node<br /><br />ls /usr/local/bin//node<br /><br />sudo ls /usr/local/bin//node<br /><br />sudo ls /usr/local/bin/node<br /><br />sudo ls /usr/local/bin//node<br /><br />nodejs -v<br /><br />echo $PATH<br /><br />ls /usr/local/bin/<br /><br />ls -l /usr/local/bin/<br /><br />which node<br /><br />ls /usr/bin<br /><br />ls /usr/bin/no*<br /><br />sudo ln -fs /usr/bin/node /usr/local/bin/nodejs<br /><br />nodejs -v<br /><br />sudo npm install -g carto<br /><br />sudo npm install -g npm@9.6.5<br /><br />sudo npm install -g carto<br /><br />carto -v<br /><br />npm install mapnik-reference<br /><br />node -e "console.log(require('mapnik-reference'))"<br /><br />cd<br /><br />cd src/openstreetmap-carto/<br /><br />carto -a "3.0.22" project.mml > style.xml</span></span><br /></p><h1 style="text-align: left;"><span style="font-family: verdana;">Download data and load into db<br /></span></h1><p style="text-align: left;"><span> </span><br /><br /></p><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier;"><span style="font-size: x-small;">cd openstreetmap-carto/<br /><br />ls scripts/<br /><br />export POSTGRES_USER=postgres<br /><br />export PG_MAINTENANCE_WORK_MEM=256MB<br /><br />export PG_WORK_MEM=16MB<br /><br />export psql=psql<br /><br />bash scripts/tune-postgis.sh<br /><br />sudo vi /etc/postgresql/*/main/postgresql.conf<br /><br />sudo /etc/init.d/postgresql restart<br /><br />sudo apt install -y osm2pgsql<br /><br />sudo add-apt-repository -y ppa:osmadmins/ppa<br /><br />apt-key adv --keyserver keyserver.ubuntu.com --recv A438A16C88C6BE41CB1616B8D57F48750AC4F2CB<br /><br />sudo apt-get update<br /><br />sudo apt-get install -y osm2pgsql<br /><br />cd<br /><br />wget -c https://download.geofabrik.de/europe/germany/hessen-latest.osm.pbf<br /><br />ls -ltr<br /><br />sudo sysctl -w vm.overcommit_memory=1<br /><br />cd<br /><br />wget -c https://download.bbbike.org/osm/extract/planet_8.294,49.99_8.979,50.252.osm.pbf<br /><br />ls -ltr<br /><br />cd ~/src<br /><br />cd openstreetmap-carto<br /><br />export OSM2PGSQL_CACHE=${OSM2PGSQL_CACHE:-512}<br /><br />export OSM2PGSQL_NUMPROC=${OSM2PGSQL_NUMPROC:-1}<br /><br />export OSM2PGSQL_DATAFILE=${OSM2PGSQL_DATAFILE:-data.osm.pbf}<br /><br />osm2pgsql --cache $OSM2PGSQL_CACHE --number-processes $OSM2PGSQL_NUMPROC --hstore --multi-geometry --database gis --slim --drop --style openstreetmap-carto.style --tag-transform-script openstreetmap-carto.lua ~/hessen-latest.osm.pbf<br /><br />python3 -m pip install psycopg2-binary<br /><br />cd ~/src<br /><br />cd openstreetmap-carto<br /><br />scripts/get-external-data.py<br /><br />cd ~/src<br /><br />cd openstreetmap-carto<br /><br />HOSTNAME=localhost # set it to the actual ip address or host name<br /><br />psql -d gis -f indexes.sql<br /><br />psql -d gis <<\eof<br /><br />REVOKE CONNECT ON DATABASE gis FROM PUBLIC;<br /><br />GRANT CONNECT ON DATABASE gis TO "www-data";<br /><br />GRANT CONNECT ON DATABASE gis TO "jan";<br /><br />eof<br /><br />psql -d gis -c "\dt+"</span></span><br /></p><p><br /></p><h1 style="text-align: left;">Setup renderd </h1><p><br /></p><p style="margin-left: 40px; text-align: left;"><span style="font-family: courier; font-size: x-small;">mapnik-config --input-plugins<br /><br />sudo vi /etc/renderd.conf<br /><br />ls /var/run/renderd/<br /><br />ls -l /home/jan//src/openstreetmap-carto/style.xml<br /><br />grep '^;xxx=\*\*' /usr/local/etc/renderd.conf<br /><br />grep '^;xxx=\*\*' /etc/renderd.conf<br /><br />sudo cp ~/src/mod_tile/debian/renderd.init /etc/init.d/renderd<br /><br />sudo vi /etc/init.d/renderd<br /><br />sudo mkdir -p /var/lib/mod_tile<br /><br />sudo systemctl daemon-reload<br /><br />sudo systemctl start renderd<br /><br />sudo systemctl enable renderd<br /><br />sudo vi /etc/apache2/mods-available/mod_tile.load<br /><br />sudo ln -s /etc/apache2/mods-available/mod_tile.load /etc/apache2/mods-enabled/<br /><br />test -f /etc/apache2/sites-enabled/000-default.conf || sudo ln -s /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled<br /><br />sudo vi /etc/apache2/sites-enabled/000-default.conf<br /><br />sudo systemctl restart apache2<br /><br />wget --spider http://localhost/osm_tiles/0/0/0.png<br /><br />history | grep wget<br /><br />tail -1000 /var/log/syslog<br /><br />sudo tail -1000 /var/log/syslog<br /><br />wget --spider http://localhost/osm_tiles/0/0/0.png<br /><br /><br /><br />renderd -f -c /etc/renderd.conf<br /><br />sudo service renderd enable<br /><br />sudo service renderd start<br /><br />sudo tail -1000 /var/log/syslog<br /><br />sudo chown renderd /run/renderd/renderd.sock<br /><br />sudo service renderd status<br /><br />sudo chown _renderd /run/renderd/renderd.sock<br /><br />sudo chown _renderd /run/renderd/<br /><br />sudo service renderd start<br /><br />sudo tail -1000 /var/log/syslog<br /><br />sudo vi /etc/renderd.conf<br /><br />sudo vi /etc/init.d/renderd<br /><br />wget --spider http://localhost/osm_tiles/0/0/0.png<br />wget http://localhost/osm_tiles/1/0/1.png<br />wget http://localhost/osm_tiles/11/0/1.png<br /><br /> </span></p>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-88606890797868321662012-04-23T20:57:00.003+02:002012-04-23T20:57:45.390+02:00Video recording of Interactive Selenium with Groovy<div dir="ltr" style="text-align: left;" trbidi="on">A fifteen minutes video shows how Selenium can be used interactively with a groovy console. <a href="http://www.youtube.com/watch?v=IlfLfLuceWk">http://www.youtube.com/watch?v=IlfLfLuceWk</a></div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-17756805734244515792012-03-26T22:37:00.000+02:002012-03-26T22:37:58.491+02:00Create a groovy console and bind to selenium<div dir="ltr" style="text-align: left;" trbidi="on">
<h1>
Required groovy files</h1>
In the previous posting we defined the pom file that we need for our build environment.
Now we will setup some groovy files to get selenium and groovy running interactively.
<br />
<h2>
ConsoleWaiter.groovy</h2>
The idea of Groovy Console I found on some other sides. Honour goes for instance too:
<a href="http://josefbetancourt.wordpress.com/tag/eclipse-2/">http://josefbetancourt.wordpress.com/tag/eclipse-2/</a>
I copied some code of this, and put it under src/test/groovy/com/jankester/selenium/test/utils:
<br />
<pre>package com.jankester.selenium.test.utils
/**
* File: ConsoleWaiter.groovy
*/
import groovy.lang.Binding;
import groovy.ui.Console;
/**
* Provides a wrapper for the console.
*
* Based on source by John Green
* Adapted from: http://www.oehive.org/files/ConsoleWaiter.groovy
* Released under the Eclipse Public License
* http://www.eclipse.org/legal/epl-v10.html
*
* I added methods to allow use from Java.
*
* The run() method launches the console and causes this thread
* to sleep until the console's window is closed.
* Allows easy interaction with the objects alive at a given
* point in an application's execution, like in a debugger
* session.
*
* Example 1:
<pre> * new ConsoleWaiter().run()
*</pre>
*
* Example 2:
<pre> * def waiter = new ConsoleWaiter()
* waiter.console.setVariable("node", node)
* waiter.run()
*</pre>
*/
class ConsoleWaiter {
Console console
Object source
boolean done = false;
/** */
public ConsoleWaiter(Console inConsole){
this.console = inConsole
}
/** */
public ConsoleWaiter(Object source){
console =
new Console(getClass().classLoader,
new Binding())
this.source = source
console.setVariable("source", source)
}
/** */
public void setVar(String key, Object value){
console.setVariable(key, value)
}
/** */
public void setVar(String key, List values){
console.setVariable(key, values)
}
/** */
public void setVar(String key, Object[] values){
console.setVariable(key, values)
}
/** */
public void run() {
console.run()
// I'm a little surprised that this exit() can be private.
console.frame.windowClosing = this.&exit
console.frame.windowClosed = this.&exit
while (!done) {
sleep 1000
}
}
/** */
public boolean isDone(){
return done;
}
/** */
public void exit(EventObject evt = null) {
done = true
}
/** */
public Console getConsole(){
return console;
}
}
</pre>
The Groovy console is supposed to get started by my main program, and blocks the thread of my main program. Only when you close the Groovy Console, the main program will continue (and exit).
You can give the groovy console a binding, and thus put it in direct contact with any context you set up before. In our case, we want to have selenium driver loaded in our context.
<br />
<h2>
Selenium setup</h2>
The groovy class to start our selenium, uses following code:
<br />
<pre>package com.jankester.selenium.test
import java.io.File
import java.util.logging.Level
import org.apache.log4j.LogManager
import org.apache.log4j.Logger
import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriverService
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.ie.InternetExplorerDriver
import org.openqa.selenium.logging.LoggingPreferences
import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.remote.RemoteWebDriver
import org.openqa.selenium.logging.LogType
import org.openqa.selenium.remote.CapabilityType
import com.opera.core.systems.OperaDriver
class WebDriverSetup {
private static WebDriverSetup setup;
protected static Logger logger = LogManager.getLogger(WebDriverSetup.class);
protected WebDriver driver;
protected Utils utils;
protected String startUrl;
protected String username;
protected String password;
public static WebDriverSetup getInstance() {
if (setup == null) {
setup = new WebDriverSetup();
}
}
private WebDriverSetup() {
startUrl = PropertyHolder.testProperties.getProperty("StartUrl");
String browser = PropertyHolder.testProperties.getProperty("BrowserType");
username = PropertyHolder.testProperties.getProperty("LoginUserName");
password = PropertyHolder.testProperties.getProperty("LoginPassword");
if (browser.equalsIgnoreCase("*firefox")) {
driver = getFirefoxDriver();
logger.info("Started firefox driver");
}
else if (browser.equalsIgnoreCase("*iexplore")) {
driver = getIEDriver();
logger.info("Started internetexplorer driver");
}
else if (browser.equalsIgnoreCase("*googlechrome")) {
driver = getGoogleChromeDriver();
logger.info("Started Googlechrome driver");
}
else if (browser.equalsIgnoreCase("*opera")) {
driver = new OperaDriver();
logger.info("Started opera driver");
}
/* open the url */
logger.info("Connecting to starturl: " + startUrl);
driver.get(startUrl);
logger.info("Connected to starturl");
}
private WebDriver getFirefoxDriver() {
logger.info("Starting firefox driver");
DesiredCapabilities caps = DesiredCapabilities.firefox();
FirefoxProfile firefoxProfile = new FirefoxProfile();
caps.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
//use setting in log4j to switch on logging of firefox driver
Logger log4jLogger = LogManager.getLogger("org.openqa");
if (log4jLogger.isInfoEnabled()) {
LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.DRIVER, Level.INFO);
caps.setCapability(CapabilityType.LOGGING_PREFS, logs);
logger.info("Logging of firefox driver is enabled");
String userDir = System.getProperty("user.dir");
System.setProperty("webdriver.firefox.logfile", "target/firefox-console.log");
System.setProperty("webdriver.log.file","${userDir}/target/firefox-driver.log");
}
WebDriver ffDriver = new FirefoxDriver(caps);
return ffDriver;
}
private WebDriver getIEDriver() {
logger.info("Starting iexplorer driver");
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
InternetExplorerDriver ieDriver = new InternetExplorerDriver(ieCapabilities);
return ieDriver;
}
private WebDriver getGoogleChromeDriver() {
logger.info("Starting googlechrome driver");
DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();
System.setProperty("webdriver.chrome.driver", PropertyHolder.testProperties.("ChromedriverPath"));
ChromeDriverService service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File(PropertyHolder.testProperties.("ChromedriverPath")))
.usingAnyFreePort().build();
logger.info("Starting chrome driver service..");
service.start();
WebDriver driverGC = new RemoteWebDriver(service.getUrl(),chromeCapabilities);
return driverGC;
}
public void close() {
logger.info("Closing driver now");
driver.close();
}
}
</pre>
<h2>
PropertyHolder</h2>
In our pom profiles we define several variables. They get merged into src/test/resources/test.properties. Our groovy classes need these variables, and get access to these variables over a PropertyHolder class:
<br />
<pre>package com.jankester.selenium.test
class PropertyHolder {
public static Properties testProperties = new Properties();
static {
InputStream is = PropertyHolder.class.classLoader.getResourceAsStream('test.properties');
testProperties.load(is);
//def theConfig = new ConfigSlurper().parse(is.getText());
}
}
</pre>
<h2>
RunSeleniumConsole</h2>
Now the final part is about starting the main program. You can do this with:
<br />
<pre>package com.jankester.selenium.test
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.By as By;
import com.jankester.selenium.test.SeleniumConstants as SeleniumConstants;
import com.jankester.selenium.test.utils.ConsoleWaiter;
import com.jankester.selenium.test.utils.Utils;
class RunSeleniumConsole {
private static Logger logger = LogManager.getLogger(RunSeleniumConsole.class);
static main(args) {
logger.info("Starting selenium session with console");
WebDriverSetup setup = WebDriverSetup.getInstance();
//set bindings
Actions actions = new Actions(setup.driver);
ConsoleWaiter waiter = new ConsoleWaiter(setup);
logger.info("Setting bindings for driver,actions,utils,logger");
waiter.setVar("driver", setup.driver);
waiter.setVar("actions",actions);
waiter.setVar("logger",logger);
waiter.setVar("startUrl",setup.startUrl);
waiter.setVar("By",By);
waiter.run();
setup.close();
}
}
</pre>
With this all in plae, you should be able to run your first console with:
<code>
mvn clean test -P firefox,development,run-console
</code>
You may get a failure for log4j initialisation. But you can just add a log4j.xml to your src/main/resources folder, and that problem should be solved.
Good Luck!
<br />
<h2>
Next</h2>
Remaining topics are:<br />
<ul style="text-align: left;">
<li>create your own utils directory</li>
<li>examples</li>
<li>save your groovy scripts</li>
<li>replay your saved groovy scripts as junit tests</li>
<li>add firebug xpi during startup</li>
</ul>
At the end of the series I will also add complete source code example. </div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com1tag:blogger.com,1999:blog-16758301.post-34574090394172173112012-03-26T22:17:00.000+02:002012-03-26T22:17:58.261+02:00Setting up maven project to do first interactive test<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h2>
The pom file</h2>
A basic pom file that sets up all dependencies for your interactive selenium-groovy testing contains following:
<br />
<pre><pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jankester.selenium</groupId>
<artifactId>selenium-groovy-public</artifactId>
<version>2012.03-SNAPSHOT</version>
<packaging>jar</packaging>
<name>selenium-groovy</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.selenium.version>2.20.0</project.selenium.version>
<log.root>./target</log.root>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy.maven.runtime</groupId>
<artifactId>gmaven-runtime-1.6</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${project.selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${project.selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${project.selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>${project.selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>${project.selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>${project.selenium.version}</version>
</dependency>
<!-- <dependency>
<groupId>org.seleniumhq.webdriver</groupId>
<artifactId>webdriver-common</artifactId>
<version>${project.selenium.version}</version>
</dependency> -->
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<encoding>ISO-8859-1</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>${testcase.include.pattern}</include>
</includes>
<excludes>
<exclude>**/*InProgressTest.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.gmaven
</groupId>
<artifactId>
gmaven-plugin
</artifactId>
<versionRange>
[1.3,)
</versionRange>
<goals>
<goal>generateTestStubs</goal>
<goal>generateStubs</goal>
<goal>testCompile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>development</id>
<properties>
<start.url>https://groups.google.com/forum/?fromgroups#!forum/selenium-users</start.url>
<login.username>XXX</login.username>
<login.password>YYY</login.password>
<log.root>./target</log.root>
</properties>
</profile>
<profile>
<id>integration</id>
<properties>
</properties>
</profile>
<profile>
<id>firefox</id>
<properties>
<browser.type>*firefox</browser.type>
<add.firebug.to.firefox>true</add.firebug.to.firefox>
</properties>
</profile>
<profile>
<id>iexplorer</id>
<properties>
<browser.type>*iexplore</browser.type>
</properties>
</profile>
<profile>
<id>googlechrome</id>
<properties>
<browser.type>*googlechrome</browser.type>
<webdriver.chrome.driver>${user.home}\map_creator-files\chromedriver.exe</webdriver.chrome.driver>
</properties>
</profile>
<profile>
<id>opera</id>
<properties>
<browser.type>*opera</browser.type>
</properties>
</profile>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>run-console</id>
<properties>
<testcase.include.pattern>XXX</testcase.include.pattern>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>com.jankester.selenium.test.RunSeleniumConsole</mainClass>
<arguments />
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>run-script-cat1</id>
<properties>
<testcase.include.pattern>**/Cat1Test*</testcase.include.pattern>
</properties>
</profile>
</profiles>
<repositories>
</repositories>
<pluginRepositories>
</pluginRepositories>
</project>
</code></pre>
</pre>
I don't want to explain maven, I don't want to go through this pom file in detail. But it will help you with:<br />
<ul style="text-align: left;">
<li>solving all dependencies of selenium 2.20</li>
<li>setup a profile for each browser</li>
<li>setup a profile for a test environment</li>
<li>setup a profile for a specific test target, or run-console.</li>
</ul>
All dependencies should be part of maven public repositories, so the repository setting can remain empty. When we have implemented some code, we can execute our selenium groovy console with:<br />
<code>
mvn clean test -P firefox,development,run-console
</code>
</div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-13641462739316638162012-03-21T22:11:00.000+01:002012-03-21T22:11:28.094+01:00Interactive selenium testing<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<h1>
The problem</h1>
<br />
<h2>
Location of elements</h2>
When I started using selenium, I noticed that it is not easy to do it right. First you start with IDE, but you notice, that the IDE does not really record a lot. In a next step I added firebug, and started analyzing how the elements where to be located: either by tag, id, class etc.<br />
<h2>
Junit testcase</h2>
With this information I could then create my junit testcase:<br />
<pre> @Test
public void testMapView() throws Exception {
//assert that we cannot see submenu of MapCreator
elem = driver.findElement(By.className(SeleniumConstants.MAP_SUB_MENU));
String style = elem.getAttribute("style");
assertTrue("Element must have style display off.",style.matches("display: none.*"));
logger.debug("Located element " + SeleniumConstants.MAP_SUB_MENU);
//find menu and click on mapview
elem = driver.findElement(By.id(SeleniumConstants.MAP_CONTROL));
actions.moveToElement(elem).click().perform();
//assert submenu is shown now
elem = driver.findElement(By.className(SeleniumConstants.MAP_SUB_MENU));
style = elem.getAttribute("style");
assertTrue("Element must have style display on.",style.matches("display: block.*"));
</pre>
Now this all works very nice, only, not after the first time. It took many iterations to get here.
<br />
<h2>
selenium iterations</h2>
Usual failures are, that element cannot be found:
<br />
<pre>org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"
</pre>
or, that you cannot click on an element, as it is not the top element or not visible:
<br />
<pre>Element is not currently visible and so may not be interacted with Build info:
</pre>
This kind of failures eat a lot of time. The forced me to analyze, use firebug, make some changes, and to restart my junit testcase. Every failure caused me to restart my testcase ...
<br />
<h2>
The first solution: eclipse debugger</h2>
I started running my testcases from eclipse, in debugging mode. I put my debug point at the location where it started to get interesting. Now I could see the exact state of my application. Also, with the debugger expression viewer, I could create expressions, that actually executed something:
<br />
<pre>(new Action(driver).moveToElement(elem).click().moveByOffSet(100,100).click().perform()
</pre>
Althoug the expression viewer is actually to discover calucated values, you can also use it to pass on new commands. It is running in the context of your JVM, so can directly pass commands to your selenium driver.
<br />
<h2>
Disadvantage of debugger expressions</h2>
This helped a lot, I could do better analysis, and try out before adding it to my test code. However, on any exception or failure, my debugger threw an exception, and I was out. I still had to restart my jvm. The problem is also with junit: when you get an exception, your test is over. No way to retry.
<br />
<h2>
The new solution: groovy console</h2>
The new solution is a lot more elegant:<br />
<ul style="text-align: left;">
<li>No junit test, but just a simple main program</li>
<li>Initialisation of selenium driver takes place in program, then control is handed over to a groovyconsole</li>
<li>Groovy allows for runtime compilation</li>
<li>Test scripts can be saved and replayed.</li>
</ul>
</div>
This was the real winner, and I still love it. Suddenly test automation with selenium starts to make fun again.<br />
<br />
<h2>
A simple example</h2>
When I start up my selenium-groovy, I get a swing groovy console that allows me to type selenium commands: <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-ylTm_-77EIM/T2pC2YMzrII/AAAAAAAAAKM/9PjEqJkghS0/s1600/Groovyconsoleexample1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="134" src="http://1.bp.blogspot.com/-ylTm_-77EIM/T2pC2YMzrII/AAAAAAAAAKM/9PjEqJkghS0/s320/Groovyconsoleexample1.png" width="320" /></a></div>
These are just a few lines of selenium. But the nice thing is: if they are wrong, you get a failure in your console, and you can just retry. Likewise, you can select only a few lines of your script, and only run those again.
<br />
<h2>
Coming topics</h2>
In future blogs, I will continue on this topic:<br />
<ul style="text-align: left;">
<li>code explained to setup the groovy console</li>
<li>how to setup your maven project to get this working</li>
<li>making your own utilities</li>
<li>a few more examples</li>
<li>running your recorded scripts in junit tests.</li>
</ul>
<br /><div>
<i>Stay tuned! </i></div>
</div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com3tag:blogger.com,1999:blog-16758301.post-15643294952101340482012-03-05T11:29:00.000+01:002012-03-05T11:29:23.295+01:00Logging in selenium<div dir="ltr" style="text-align: left;" trbidi="on">
For some time I am trying to get more out of Selenium. Lot has changed here: selenium2 is a big improvement, and since 2.15 google also contributed its Advanced User Interactions API to the selenium code base, which seems to be a big improvement for mouse handling.<br />
To get a better understanding of what is happening, and especially why my test scripts are failing, I wanted to control the logging of my webdriver. I noticed that this was a bit of a pain. Selenium firefox driver is using java.util.logging. So you are bound to the mechanisms that java.util.logging offers you for log configuration.<br />
<br />
This is the approach I ended up with.<br />
<ul style="text-align: left;">
<li>Before I startup my Firefox Webdriver, I used the setLogLevel method to set the Level of logging that is used for all driver logs. When you set this to WARNING, all logs that the driver makes, are considered to be WARNING logs, when you set them to FINE, all logs are considered to be FINE logs. So dependent on the settings inside your logging.properties, you will see these logs appear in your system out or not. I put the level to INFO, and now they are always appearing in my system.out output. During test development I do not mind. I will switch if off though when I move scripts to an automatic build environment.</li>
<li>To change the settings for java.util.logging, you can either configure the file under java_home/jre/lib, or set the config file explicitly over the command line with -Djava.util.logging.config.file=myfile.</li>
</ul>
I am still interested in routing Java Util Logging (JUL) to log4j. Maybe this is a solution:<br />
<a href="http://www.slf4j.org/legacy.html#jul-to-slf4j">http://www.slf4j.org/legacy.html#jul-to-slf4j</a><br />
<br /></div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com1tag:blogger.com,1999:blog-16758301.post-11753956117554717762011-10-19T08:28:00.000+02:002011-10-19T08:28:52.131+02:00Junit4 running parallel junit classes<div dir="ltr" style="text-align: left;" trbidi="on">
To run junit testcases parallel, you can create your own class to run junit with:<br />
<br />
Add this tag to your class declaration.<br />
<div style="font-family: "Courier New",Courier,monospace;">
@RunWith(Parallelized.class)</div>
<br />
Implementation of this class looks like:<br />
<div style="font-family: "Courier New",Courier,monospace;">
package mypackage;<br />import java.util.concurrent.ExecutorService;<br />import java.util.concurrent.Executors;<br />import java.util.concurrent.TimeUnit;<br /><br />import org.junit.runners.Parameterized;<br />import org.junit.runners.model.RunnerScheduler;<br /><br />public class Parallelized extends Parameterized<br />{<br /> <br /> private static class ThreadPoolScheduler implements RunnerScheduler<br /> {<br /> private ExecutorService executor; <br /> <br /> public ThreadPoolScheduler()<br /> {<br /> String threads = System.getProperty("junit.parallel.threads", "16");<br /> int numThreads = Integer.parseInt(threads);<br /> executor = Executors.newFixedThreadPool(numThreads);<br /> }<br /> <br /> public void finished()<br /> {<br /> executor.shutdown();<br /> try<br /> {<br /> executor.awaitTermination(10, TimeUnit.MINUTES);<br /> }<br /> catch (InterruptedException exc)<br /> {<br /> throw new RuntimeException(exc);<br /> }<br /> }<br /><br /> public void schedule(Runnable childStatement)<br /> {<br /> executor.submit(childStatement);<br /> }<br /> }<br /><br /> public Parallelized(Class klass) throws Throwable<br /> {<br /> super(klass);<br /> setScheduler(new ThreadPoolScheduler());<br /> }<br />}</div>
<div style="font-family: "Courier New",Courier,monospace;">
<br /></div>
Now inside your test class, you will need to create a method with<br />
<div style="font-family: "Courier New",Courier,monospace;">
@Parameters</div>
tag declaration, that feeds the constructor:<br />
<br />
<span style="font-family: "Courier New",Courier,monospace;"> public PocAddPoiTest(String browser) {</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> super();</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> this.browser = browser;</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> }</span><br style="font-family: "Courier New",Courier,monospace;" /><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> @Parameters</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> public static Collection browsersStrings() {</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> // return Arrays.asList(new Object[][] { { "*firefox" },</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> // { "*googlechrome" } });</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> return Arrays.asList(new Object[][] { { "*firefox","*iexplore" } });</span><br style="font-family: "Courier New",Courier,monospace;" /><span style="font-family: "Courier New",Courier,monospace;"> }</span><br />
<br />
When junit gets started, it will run two tests parallel.<br />
<br />
Not sure how it handles output .. :-).</div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-34662572408462949482011-09-22T17:51:00.001+02:002011-09-22T17:55:52.818+02:00Run jmeter from eclipse<div dir="ltr" style="text-align: left;" trbidi="on">
Download jmeter source and binaries:
<a href="http://archive.apache.org/dist/jakarta/jmeter/binaries/jakarta-jmeter-2.3.4.zip">http://archive.apache.org/dist/jakarta/jmeter/binaries/jakarta-jmeter-2.3.4.zip</a>
<a href="http://archive.apache.org/dist/jakarta/jmeter/source/jakarta-jmeter-2.3.4_src.zip">http://archive.apache.org/dist/jakarta/jmeter/source/jakarta-jmeter-2.3.4_src.zip</a>
<br />
<br />
Unpack jmeter source file, and rename eclipse.classpath into .classpath.
Add a .project file to the same directory:
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code><?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jakarta-jmeter-2.3.4</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
</code></pre>
Now import the source code as eclipse project.<br />
<br />
Add all libs of binary distribution (lib/*.jar) to the new project's lib dir.<br />
Add all files, except ApacheJmeter.jar (bin/**/*) to the new project's bin dir.<br />
<br />
<br />
Clean eclipse project.<br />
Run ant package on the build.xml file to create the RMI jars.<br />
<br />
<br />
Create a launcher for org.apache.jmeter.NewDriver and set arguments/working directory to: ${workspace_loc:jakarta-jmeter-2.3.4/bin}.
<br />
When you start the launcher, jmeter comes up.
<br />
<br />
With the same configuration you can also debug. Add a debug breakpoint to for instance:
<code>
org.apache.jmeter.engine.StandardJMeterEngine.runTest()
</code>
<br />
Start your debug session now, and run example script. It will wait when you start a test run.
<br />
<br />
To debug your own project (with sampler for instance):<br />
<ul style="text-align: left;">
<li>make your own project dependent on jakarta-jmeter project</li>
<li> check that all jars from jakarta-jmeter project are exported</li>
<li>duplicate the launcher of above, but replace project by your own now</li>
<li>make sure your working directory is still pointing to jakarta-jmeter project's bin directory</li>
<li>check that your own src directory of sampler is on the classpath of the launcher</li>
<li>launch jmeter with this project's launcher</li>
<li>add debug breakpoints to sampler's code</li>
</ul>
</div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com3tag:blogger.com,1999:blog-16758301.post-14505296045852117142011-09-22T16:56:00.000+02:002011-09-22T16:56:58.228+02:00Debugging against jmeter<div dir="ltr" style="text-align: left;" trbidi="on">
Inside jmeter startup script, add:<br />
<pre>
set DEBUGJDWP=-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=y
set ARGS=%DUMP% %HEAP% %NEW% %SURVIVOR% %TENURING% %EVACUATION% %RMIGC% %PERM% %DDRAW% %DEBUGJDWP%
</pre>
Now start jmeter. It will hang and wait for debugger.
<br/><br/>
In eclipse, add a new remote java application debug configuration.
Add jmeter source code to it. Connect.
Jmeter will start now.
<br/><br/>
Attach jmeter source code. Lookup class:
<pre>
org.apache.jmeter.engine.StandardJMeterEngine
</pre>
Set debug point in runTest() method and start your script.
</div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-61697355179562337242011-08-03T14:57:00.000+02:002011-08-03T14:57:57.695+02:00Good principles of test automation<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Core principles of good tests</b><br />When you start automating your tests, there a few important principles to stick to.<br />
<br />
<b>Reliable </b><br />
First your tests must be reliable. This means that they must repeatable and always give the same results. They should not contain any environment dependencies, and be executable on any environment. To get this working, all hard-coded settings must be configurable, a maven or ant script is required to build and configure the test environment, and all code, test date and configuration scripts must be checked in source code repository. Having reliable tests that run everywhere and always, also means that your tests must take care to setup necessary test data, and clean it afterward again.<br />
<br />
<br />
<b>Fast</b><br />Next, it would be nice when your tests are fast. In the lifetime of a project you will build up ever more tests; with every next sprint you will need to run more tests. You can't run all your tests on check-in, and for certain groups of tests need to schedule test execution times at less regular intervals.<br /><br />
<b>Self explaining tests</b><br />
Also your tests should be easy to understand, and have clean reports. Easy to understand means that an outsider can quickly understand what the test is about. Proper naming helps a lot here, additionally you can add document tags to the comments. It also helps to stick to the domain language so that it is easy to map test cases to use cases.<br />
<br />
<br />
<br />
<b>Clean reports</b><br />Test reports should have a clean baseline. Try to avoid including known bugs, as they clog up the test results, and make the news bugs less visible. Also in your asserts add meaningful log statements that help finding the root cause of the failure.<br /><br /><b>Continous integration </b><br />
Further you want your tests be integrated in continous integration build process. You will probably want to create several groups and have some of these more frequently executed than others. Once you have them running automatically, you are sure that they actually get executed, and you also make sure that they are really reproducible. Before you add your tests to CI you must make sure though that your test reports have a clean baseline. Else people will ignore the test reports. <br />
<br />
<br /><b>Continuous integration of test environment setup </b><br />
Deployment and execution of tests in CI environments is the easy part. Far more difficult it may be to set up and configure your test environment. This includes setting up your application server, initialising your database, starting your application server, deploying your application and configuration of appl server and application. This will require a lot of specialist knowledge. <br />One step further you may also want to mock your connection proxies to external connections. This may be for instance a credit card provider. You don't want to send your payments that you generate in tests to a real provider. So you will need to mock the provider's functionality and have your test environment set up with this mock interface instead of the real one. <br />
<br /><b>Testability </b><br />
A last point of attention concerns testability. Some of your application's functionality may be difficult to test as you can't reach it with your testing code. Examples could be a status of an object that you have just changed, and can only be checked by a UI application. As a tester you would like to have direct access to this functionality, so that you can use it for the asserts of the test. These testability functionalities are additional requests to the developers. They will need to build it in the code, just for the sake of testing. Other important testability examples are: fixed IDs for html elements, or some deleteFunctionality to clean up test generated objects.</div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-50748911527224757082011-08-03T14:54:00.000+02:002011-08-03T14:54:10.873+02:00Test automation in agile<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Test automation importance</b><br />
With our change to agile, we have made an important paradigm shift. In the old days we would stick to our planned roadmap, and compromise either on delivery dates or software quality. In Agile software development we are willing to compromise on scope, but not on software quality or delivery dates. This means in short: no code goes out untested.<br />
<b> </b><br />
<b>What tests to execute?</b><br />
It is nearly impossible to test everything. There are so many types of tests, like: regression, story acceptance, developer, integration, usability, performance, security, upgrade, user acceptance etc. In our release planning, we must make a conscious decision which of those types we want to execute. Some of the test types may require additional experts, some of the tests may not be relevant, some may be just too costly.
<b> </b><br />
<br />
<b>The usual scrum tests</b>
Within our sprints, we tend to stick to regression tests, story acceptance tests, developer tests and integration tests. Developer tests are internal component tests, that test a component directly without the need of other components. Integration tests review the interaction between two or more components. Story acceptance tests verify the acceptance criteria. Regression tests are the story acceptance tests of previous sprints and may also include parts of the integration tests.<br />
<b> </b><br />
<b>Which tests to automate?</b><br />
For some tests it may not make sense to automate. Will the test ever be executed again? If not, then it will probably not pay off to automate it. Also consider the cost of test automation versus the time needed to test manually. Especially for UI tests, it may be cheaper to do manual tests. Drag and drop, and visual control of the result are very hard to automate. For normal webforms or low level service tests, automation is efficient.
<b> </b><br />
<br />
<b>What are the risks of not automating?</b><br />
It is likely, that those tests that we decided not to automate, will not be executed in future sprints. So future sprints may break existing functionality without us knowing it. With less test coverage, we will get afraid to refactor our code. In the extreme case, we would end up with an application that we don't dare to touch. So it is very important to have automated regression tests with good coverage.
</div>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com1tag:blogger.com,1999:blog-16758301.post-14537351186797562072011-03-15T11:41:00.002+01:002011-03-15T11:47:47.629+01:00SSL handshake failed: Secure connection truncatedGot this problem on Ubuntu 9.10 and 10.10.
<pre>
svn co --username=xx https:/yy zz
“SSL handshake failed: Secure connection truncated”
</pre>
According to this link <a href="https://bugs.launchpad.net/ubuntu/+source/subversion/+bug/294648">bug-ubuntu</a>
The solution is:
<pre>
sudo apt-get install libneon27
cd /usr/lib/
sudo rm libneon-gnutls.so.27
sudo ln -s /usr/lib/libneon.so.27 libneon-gnutls.so.27
</pre>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com13tag:blogger.com,1999:blog-16758301.post-79465650082492625632010-06-05T10:40:00.000+02:002010-06-05T10:40:55.818+02:00Grinderstone under linuxI am using Ubuntu 9.10
<pre>
jan@albotek:~/development/eclipse$ more /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"
</pre>
I installed new eclipse 3.5.2, and inside eclipse used jdk 1.6.0.20 as default JRE, and jython 2.5.1 for my jython. Still I did not manage to get my grinder scripts with proxy working. The failure I was getting:
<pre>
Java exception initialising test script
test1.record(grinder.getLogger().output)
File "/home/jan/development/workspace-grinder/Grinder1/src/HelloWorld3.py", line 7, in Caused by: net.grinder.script.NonInstrumentableTypeException: Failed to wrap <bound method net.grinder.engine.process.ExternalLogger.output of net.grinder.engine.process.ExternalLogger@1190ea0>
at net.grinder.engine.process.instrumenter.MasterInstrumenter.instrument(MasterInstrumenter.java:114)
at net.grinder.engine.process.TestData.instrument(TestData.java:100)
at net.grinder.script.Test.record(Test.java:114)
</pre>
In my output log I was seeing:
<pre>
6/5/10 10:22:09 a.m. (process albotek-0): The Grinder version 3.4
6/5/10 10:22:09 a.m. (process albotek-0): null 1.5.0: GNU libgcj (4.4.1, GNU libgcj 4.4.1) on Linux i386 2.6.31-21-generic
6/5/10 10:22:09 a.m. (process albotek-0): time zone is GMT+02:00 (+0200)
6/5/10 10:22:21 a.m. (process albotek-0): worker process 0
6/5/10 10:22:21 a.m. (process albotek-0): Java VM does not support instrumentation, DCR unavailable
6/5/10 10:22:21 a.m. (process albotek-0): instrumentation agents: NO INSTRUMENTER COULD BE LOADED
6/5/10 10:22:21 a.m. (process albotek-0): executing "/home/jan/development/workspace-grinder/Grinder1/src/HelloWorld3.py" using Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
</pre>
Apparently I was using the wrong java version. Although I set it explicitly inside eclipse, eclipse itself had been started with java from OS, and grinderstone is using that one for its execution.
I made a small startup script for my eclipse:
<pre>
export GDK_NATIVE_WINDOWS=true
./eclipse -clean -console -consoleLog -vm /usr/lib/jvm/java-6-sun/bin/java -vma
rgs -Xmx400M -XX:MaxPermSize=128M -Dorg.eclipse.swt.browser.XULRunnerPath=/usr/l
ib/xulrunner/xulrunner
</pre>
and when I now start my eclipse, I get:
<pre>
6/5/10 10:30:24 AM (process albotek-0): The Grinder version 3.4
6/5/10 10:30:24 AM (process albotek-0): Java(TM) SE Runtime Environment 1.6.0_20-b02: Java HotSpot(TM) Server VM (16.3-b01, mixed mode) on Linux i386 2.6.31-21-generic
6/5/10 10:30:24 AM (process albotek-0): time zone is CEST (+0200)
6/5/10 10:30:29 AM (process albotek-0): worker process 0
6/5/10 10:30:29 AM (process albotek-0): instrumentation agents: byte code transforming instrumenter for Jython 2.5; byte code transforming instrumenter for Java
6/5/10 10:30:29 AM (process albotek-0): executing "/home/jan/development/workspace-grinder/Grinder2/src/HelloWorld3.py" using Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
</pre>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-40248781299441550832010-06-04T17:05:00.000+02:002010-06-04T17:05:20.632+02:00Grinderstone and instrumentationAt least I got my office PC (windows) working now.
Script is:
<pre>
# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP.
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPRequest
test1 = Test(1, "Request resource")
request1 = test1.wrap(HTTPRequest())
class TestRunner:
def __call__(self):
result = request1.GET("http://emeafraippqa08:80/")
</pre>
I used to get failures that had to do with instrumentation.
In the end I added a new jdk6 (1.6.0.20) to eclipse, renewed my jython 2.5.1 reference so that it is using these libs, and now got it working.
In my console I see the following path:
<pre>
04.06.10 17:03:42 (agent): The Grinder 3.4
04.06.10 17:03:42 (agent): Worker process command line: java '-javaagent:C:\development\grinder-3.4\lib\grinder-agent.jar' -classpath 'C:\development\jython2.5.1\jython.jar;C:\Dokumente und Einstellungen\jan.kester\workspace\Grinder1/srcC:\development\grinder-3.4\lib\grinder-agent.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\eclipse_3.5.2\plugins\org.python.pydev_1.5.7.2010050621\PySrc\pydev_sitecustomize;C:\Dokumente und Einstellungen\jan.kester\workspace\Grinder1\src;C:\development\grinder-3.4\lib\grinder-agent.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\jython2.5.1\Lib;C:\development\jython2.5.1\Lib\site-packages;C:\Programme\Java\jdk1.6.0_20\jre\lib\resources.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\rt.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\jsse.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\jce.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\charsets.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\ext\dnsns.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\ext\localedata.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\ext\sunjce_provider.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\ext\sunmscapi.jar;C:\Programme\Java\jdk1.6.0_20\jre\lib\ext\sunpkcs11.jar' net.grinder.engine.process.WorkerProcessEntryPoint
04.06.10 17:03:43 (agent): worker emeafralp560-0 started
04.06.10 17:03:45 (process emeafralp560-0): starting threads
04.06.10 17:03:48 (process emeafralp560-0): finished
04.06.10 17:03:49 (agent): finished
</pre>
My direct grinder output is:
<pre>
C:\development\grinder-3.4>startAgent_jython251.cmd
C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;.;C:\Programme\Java\jre6\lib\ext\QTJava.zip
6/4/10 2:09:53 PM (agent): The Grinder 3.4
6/4/10 2:09:53 PM (agent): Worker process command line: java '-javaagent:C:\development\grinder-3.4\lib\grinder-agent.jar' '-Dpython.home=C:/development/jython2.5.1' '-Dpython.cachedir=C:\development\grinder-3.4/cachedir' -classpath 'C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:/development/jython2.5.1/jython.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;C:\development\grinder-3.4\lib\grinder.jar;.;C:\Programme\Java\jre6\lib\ext\QTJava.zip' net.grinder.engine.process.WorkerProcessEntryPoint
6/4/10 2:09:54 PM (agent): worker emeafralp560-0 started
04.06.10 14:09:55 (process emeafralp560-0): starting threads
04.06.10 14:09:55 (process emeafralp560-0): finished
6/4/10 2:09:56 PM (agent): finished
</pre>
Now I need to get my home PC working still ... (Ubuntu)Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-179785775006322732010-06-04T14:12:00.002+02:002010-06-04T14:12:54.060+02:00record() not wrap()With the new jython 2.5.1 instrumentation, you must use record() method of Test proxy, and not wrap(). The old one is deprecated.
The difference:
old:
<pre>
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
test1 = Test(1, "Log method")
# Wrap the output() method with our Test and call the result logWrapper.
logWrapper = test1.wrap(grinder.getLogger().output)
class TestRunner:
def __call__(self):
logWrapper("Hello World2")
</pre>
new:
<pre>
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
test1 = Test(1, "Log method")
# Instrument the output() method with our Test.
test1.record(grinder.getLogger().output)
class TestRunner:
def __call__(self):
grinder.getLogger().output("Hello World4")
</pre>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-33855097700507328032010-06-04T14:01:00.000+02:002010-06-04T14:01:02.810+02:00Using grinder 3.4 and jython 2.5.1By default grinder 3.4 comes with a jython jar under lib directory. It is version 2.2.1.
In order two use a newer jython, you need to change two settings:<br />
<ul>
<li>add your newest jython jar in front of classpath</li>
<li>add a jvm property that directs python_home to the home of your jython.</li>
</ul>
You can either do this in grinder.properties or in your bat script that starts the agent. I prefer the latter as I would like to keep grinder.properties as general as possible, independent of machines/environment.
My new startAgent_jython251.cmd script looks like:
<pre>
@echo off
set GRINDERPATH=C:\development\grinder-3.4
call %GRINDERPATH%\setGrinderEnv.cmd
set PYTHON_HOME=C:/development/jython2.5.1
echo %CLASSPATH%
set CLASSPATH=%PYTHON_HOME%/jython.jar;%CLASSPATH%
set JVMARGS="-Dpython.home=%PYTHON_HOME% -Dpython.cachedir=%GRINDERPATH%/cachedir"
java -Duser.language="en" -Dgrinder.jvm.arguments=%JVMARGS% -cp %CLASSPATH% net.grinder.Grinder %GRINDERPROPERTIES%
</pre>
When I run a script with this agent cmd, my output looks like:
<pre>
04.06.10 13:53:46 (process emeafralp560-0): The Grinder version 3.4
04.06.10 13:53:46 (process emeafralp560-0): Java(TM) SE Runtime Environment 1.6.0_20-b02: Java HotSpot(TM) Client VM (16.3-b01, mixed mode) on Windows XP x86 5.1
04.06.10 13:53:46 (process emeafralp560-0): time zone is MESZ (+0200)
04.06.10 13:53:48 (process emeafralp560-0): worker process 0
04.06.10 13:53:48 (process emeafralp560-0): instrumentation agents: byte code transforming instrumenter for Jython 2.5; byte code transforming instrumenter for Java
04.06.10 13:53:48 (process emeafralp560-0): executing "C:\development\grinder-3.4\HelloGrinder3.py" using Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)]
</pre>
I think that by default it is already using the new instrumentation implementation that gets used by jython 2.5.1. Manual states namely that if you use the old one, the output shows you
<blockquote>traditional Jython instrumenter</blockquote>
I did not see it, and could not influence the output with parameter
<blockquote>grinder.dcrinstrumentation = true</blockquote>
So I compared behaviour with a grinder using jython 2.2.1. There using this parameter did make an influence. If you included the parameter, regardless the value you are giving it (true|anything|even-false|false), it will use the new way of instrumentation. Only when you leave the parameter out, you will get output:
<pre>
04.06.10 14:00:34 (process emeafralp560-0): The Grinder version 3.4
04.06.10 14:00:34 (process emeafralp560-0): Java(TM) SE Runtime Environment 1.6.0_20-b02: Java HotSpot(TM) Client VM (16.3-b01, mixed mode) on Windows XP x86 5.1
04.06.10 14:00:34 (process emeafralp560-0): time zone is MESZ (+0200)
04.06.10 14:00:34 (process emeafralp560-0): worker process 0
04.06.10 14:00:34 (process emeafralp560-0): instrumentation agents: traditional Jython instrumenter; byte code transforming instrumenter for Java
04.06.10 14:00:34 (process emeafralp560-0): executing "C:\development\grinder-3.4\HelloGrinder3.py" using Jython 2.2.1
</pre>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-12637744346979913902010-06-04T13:19:00.000+02:002010-06-04T13:19:21.790+02:00My first grinder runsI downloaded grinder 3.4, and unpacked.
I installed java jdk 1.6.0.20 on my machine.
Inside the root directory of my installation I added following scripts:
setGrinderEnv.cmd
<pre>
set GRINDERPATH=C:\development\grinder-3.4
set GRINDERPROPERTIES=C:\development\grinder-3.4\grinder.properties
set CLASSPATH=%GRINDERPATH%\lib\grinder.jar;%CLASSPATH%
set JAVA_HOME=C:\Programme\Java\jdk1.6.0_20
PATH=%JAVA_HOME%\bin;%PATH%
</pre>
startProxy.cmd
<pre>
set GRINDERPATH=C:\development\grinder-3.4
call %GRINDERPATH%\setGrinderEnv.cmd
echo %CLASSPATH%
java -Duser.language="en" -cp %CLASSPATH% net.grinder.TCPProxy -console -http > ipp.py
</pre>
startConsole.cmd
<pre>
set GRINDERPATH=C:\development\grinder-3.4
call %GRINDERPATH%\setGrinderEnv.cmd
echo %CLASSPATH%
java -Duser.language="en" -cp %CLASSPATH% net.grinder.Console
</pre>
startAgent.cmd
<pre>
set GRINDERPATH=C:\development\grinder-3.4
call %GRINDERPATH%\setGrinderEnv.cmd
echo %CLASSPATH%
java -Duser.language="en" -cp %CLASSPATH% net.grinder.Grinder %GRINDERPROPERTIES%
</pre>
I also dropped a file grinder.properties in root directory of grinder-3.4:
<pre>
grinder.script=HelloGrinder2.py
grinder.processes = 1
grinder.threads = 3
grinder.runs = 2
grinder.useConsole = false
grinder.dcrinstrumentation = true
grinder.logDirectory = logs
grinder.numberOfOldLogs = 0
grinder.initialSleepTime=50
</pre>
With this grinder.properties, an agent will execute the HelloGrinder2.py script:
<pre>
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
test1 = Test(1, "Log method")
# Wrap the output() method with our Test and call the result logWrapper.
logWrapper = test1.wrap(grinder.getLogger().output)
class TestRunner:
def __call__(self):
logWrapper("Hello World2")
</pre>
I can execute the script by calling startAgent.cmd.
After execution I get a subdirectory called log, with data and output files in it.
The output file shows:
<pre>
04.06.10 10:47:40 (process emeafralp560-0): starting threads
04.06.10 10:47:40 (thread 2): starting, will do 2 runs
04.06.10 10:47:40 (thread 1): starting, will do 2 runs
04.06.10 10:47:40 (thread 0): starting, will do 2 runs
04.06.10 10:47:40 (process emeafralp560-0): start time is 1275641260135 ms since Epoch
04.06.10 10:47:40 (thread 0): sleeping for 10 ms
04.06.10 10:47:40 (thread 1): sleeping for 1 ms
04.06.10 10:47:40 (thread 2): sleeping for 4 ms
04.06.10 10:47:40 (thread 2 run 0 test 1): Hello World2
04.06.10 10:47:40 (thread 1 run 0 test 1): Hello World2
04.06.10 10:47:40 (thread 0 run 0 test 1): Hello World2
04.06.10 10:47:40 (thread 1 run 1 test 1): Hello World2
04.06.10 10:47:40 (thread 1 test 1): finished 2 runs
04.06.10 10:47:40 (thread 0 run 1 test 1): Hello World2
04.06.10 10:47:40 (thread 0 test 1): finished 2 runs
04.06.10 10:47:40 (thread 2 run 1 test 1): Hello World2
04.06.10 10:47:40 (thread 2 test 1): finished 2 runs
04.06.10 10:47:40 (process emeafralp560-0): elapsed time is 22 ms
</pre>
As my grinder properties file tells to use 3 threads, and 2 runs for each thread, the Hello World2 got written 6 times.
My data output shows the test times that the Test Proxy of the script recorded:
<pre>
Thread, Run, Test, Start time (ms since Epoch), Test time, Errors
0, 0, 1, 1275641260152, 0, 0
1, 0, 1, 1275641260152, 0, 0
2, 0, 1, 1275641260152, 1, 0
1, 1, 1, 1275641260153, 0, 0
0, 1, 1, 1275641260154, 0, 0
2, 1, 1, 1275641260154, 0, 0
</pre>
This output is a bit boring, as I did not make any http request.
With the next file HelloGrinder3.py I do:
<pre>
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPRequest
test1 = Test(1, "Request resource")
request1 = test1.wrap(HTTPRequest())
class TestRunner:
def __call__(self):
result = request1.GET("http://emeafraippqa08:80/")
</pre>
I need to adapt grinder.properties to use this as grinder.script, and then can run startAgent.cmd again.
Now my data output looks like:
<pre>
Thread, Run, Test, Start time (ms since Epoch), Test time, Errors, HTTP response code, HTTP response length, HTTP response errors, Time to resolve host, Time to establish connection, Time to first byte
1, 0, 1, 1275650338473, 60, 0, 200, 327, 0, 23, 33, 50
1, 1, 1, 1275650338535, 2, 0, 200, 327, 0, 0, 0, 1
2, 0, 1, 1275650338473, 3105, 0, 200, 327, 0, 22, 3085, 3094
0, 0, 1, 1275650338481, 3097, 0, 200, 327, 0, 23, 3085, 3094
2, 1, 1, 1275650341579, 5, 0, 200, 327, 0, 0, 1, 3
0, 1, 1, 1275650341579, 7, 0, 200, 327, 0, 0, 1, 2
</pre>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-17862262281679579662010-06-03T20:17:00.000+02:002010-06-03T20:17:22.889+02:00Adding your own stylesTo get nice formatting of your blog, you can add your own style elements.
Under Customize - Layout - Edit Html you can adapt your style sheet.
Find the element:
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>]]></b:skin>
</head>
</code></pre>
and above this add:
<pre>
pre {
background:#eeeeee;
border:1px solid #A6B0BF;
font-size:120%;
line-height:100%;
overflow:auto;
padding:10px;
color:#000000 }
pre:hover {
border:1px solid #efefef;
}
code {
font-size:120%;
text-align:left;
margin:0;padding:0;
color: #000000;}
.clear { clear:both;
overflow:hidden;
}
</pre>
Now you have two new styles you can use: pre and code.
To use them, switch to Edit HTML mode, and use html tags pre or code.Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-84072352578776592002010-06-02T16:29:00.002+02:002010-06-03T20:20:38.369+02:00My first grinderstone projectI followed instructions to set up grinderstone:<br />
<ul>
<li>eclipse 3.5.2 </li>
<li>pydev from update site </li>
<li>grinderstone from update site</li>
<li>jython 2.5.1 installed</li>
<li>grinder 3.4 installed</li>
</ul>
Under windows preferences I added a jython 2.5.1 jar as jython interpreter. It asks which libraries to include on the python system path. I choose the defaults, excluding __pyclasspath__ and __classpath__. Not sure where these get used for; probably to include your project's .classpath or python path in the jython execution's classpath.<br />
Also under windows-preferences, I set show whitespace characters to true.<br />
<br />
Next I create a python project. I added grinder.jar and grinder-agent.jar to the external libraries of the project build path. Now I can add my first grinder file under src/HelloGrinder.py:<br />
<pre>
from net.grinder.script.Grinder import grinder<br />
<br />
# An instance of this class is created for every thread.<br />
class TestRunner:<br />
# This method is called for every run.<br />
def __call__(self):<br />
# Per thread scripting goes here.<br />
grinder.getLogger().output("Hello World")</pre>
<br />
Next I need to add a grinder.properties to the directory as well:<br />
<pre>
grinder.processes = 1<br />
grinder.threads = 1<br />
grinder.runs = 1<br />
grinder.useConsole = false<br />
grinder.logDirectory = logs<br />
grinder.numberOfOldLogs = 0<br />
grinder.initialSleepTime=50</pre>
I can now select my HelloGrinder.py file, and with right mouse button select: Run As - Grinder Run.<br />
Logs will appear under src. You will need to click refresh (F5) on you project before they get visible ..<br />
<br />
Output looks like:<br />
<pre>
02.06.10 16:27:18 (process emeafralp560-0): The Grinder version 3.4<br />
02.06.10 16:27:18 (process emeafralp560-0): Java(TM) 2 Runtime Environment, Standard Edition 1.5.0_06-b05: Java HotSpot(TM) Client VM (1.5.0_06-b05, mixed mode) on Windows XP x86 5.1<br />
02.06.10 16:27:18 (process emeafralp560-0): time zone is CEST (+0200)<br />
02.06.10 16:27:20 (process emeafralp560-0): worker process 0<br />
02.06.10 16:27:20 (process emeafralp560-0): Java VM does not support instrumentation, DCR unavailable<br />
02.06.10 16:27:20 (process emeafralp560-0): instrumentation agents: NO INSTRUMENTER COULD BE LOADED<br />
02.06.10 16:27:20 (process emeafralp560-0): executing "C:\Dokumente und Einstellungen\jan.kester\workspace\Grinder1\src\HelloGrinder.py" using Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54) <br />
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)]<br />
02.06.10 16:27:20 (process emeafralp560-0): starting threads<br />
02.06.10 16:27:20 (thread 0): starting, will do 1 run<br />
02.06.10 16:27:20 (process emeafralp560-0): start time is 1275488840962 ms since Epoch<br />
02.06.10 16:27:20 (thread 0): sleeping for 38 ms<br />
02.06.10 16:27:20 (thread 0 run 0): Hello World<br />
02.06.10 16:27:20 (thread 0): finished 1 run<br />
02.06.10 16:27:20 (process emeafralp560-0): elapsed time is 58 ms<br />
02.06.10 16:27:20 (process emeafralp560-0): Final statistics for this process:<br />
Tests Errors Mean Test Test Time TPS <br />
Time (ms) Standard <br />
Deviation <br />
(ms) <br />
<br />
<br />
Totals 0 0 ? 0,00 ? <br />
<br />
Tests resulting in error only contribute to the Errors column. <br />
Statistics for individual tests can be found in the data file, including<br />
(possibly incomplete) statistics for erroneous tests. Composite tests <br />
are marked with () and not included in the totals. <br />
02.06.10 16:27:20 (process emeafralp560-0): finished</pre>
<br />
<br />
<br />
<br />Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-68653997621413063782010-05-04T16:20:00.002+02:002010-05-04T16:40:02.358+02:00Setting up ldap on Ubuntu 9.10Installing slapd on Ubuntu 9.10 is not enough.
The configuration of slapd requires more steps.
I refer to article:
<a href="http://doc.ubuntu.com/ubuntu/serverguide/C/openldap-server.html">http://doc.ubuntu.com/ubuntu/serverguide/C/openldap-server.html</a> which apparently also applies to 9.10.
Make sure you load the necessary schemas:
<pre>
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
</pre>
My ldif file I wanted to load contains dc=ldap,dc=example,dc=ipp. So I wanted to set up a rootdn starting with same domain.<br />
<pre>
# Load dynamic backend modules
dn: cn=module,cn=config
objectClass: olcModuleList
cn: module
olcModulepath: /usr/lib/ldap
olcModuleload: back_hdb
# Database settings
dn: olcDatabase=hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {1}hdb
olcSuffix: dc=ldap,dc=example,dc=ipp
olcDbDirectory: /var/lib/ldap
olcRootDN: cn=admin,dc=ldap,dc=example,dc=ipp
olcRootPW: secret
olcDbConfig: set_cachesize 0 2097152 0
olcDbConfig: set_lk_max_objects 1500
olcDbConfig: set_lk_max_locks 1500
olcDbConfig: set_lk_max_lockers 1500
olcDbIndex: objectClass eq
olcLastMod: TRUE
olcDbCheckpoint: 512 30
olcAccess: to attrs=userPassword by dn="cn=admin,dc=ldap,dc=example,dc=ipp" write by anonymous auth by self write by * none
olcAccess: to attrs=shadowLastChange by self write by * read
olcAccess: to dn.base="" by * read
olcAccess: to * by dn="cn=admin,dc=ldap,dc=example,dc=ipp" write by * read
</pre>
Note that I changed the domain, and left password to secret.
Load this backend file with:
<pre>
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f backend.ldap.example.ipp.ldif
</pre>
You will now need to restart your slapd daemon.
Then you can add your own ldif file with data.
Afterwards you can test with ldapsearch. As normal user:
<pre>
ldapsearch -x -b "dc=ldap,dc=example,dc=ipp" uid=User sn ginveName cn
ldapsearch -x -b "dc=ldap,dc=example,dc=ipp" '(objectclass=top)'
ldapsearch -x -b "dc=ldap,dc=example,dc=ipp" '(objectclass=domain)'
ldapsearch -x -b "dc=ldap,dc=example,dc=ipp" '(objectclass=person)'
ldapsearch -x -b "dc=ldap,dc=example,dc=ipp" '(objectclass=organizationalUnit)'
</pre>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-3284782962927306632010-05-03T11:07:00.001+02:002010-05-03T11:09:59.119+02:00Publishing xmlI always had the problem in my posts to include xml snippets. A problem other people must have experienced too. I came across the blogger site: <a href="http://formatmysourcecode.blogspot.com/">http://formatmysourcecode.blogspot.com/</a>. It allows to copy your xml, paste and convert it. An example is below, it should show xml ...<br />
<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code><?xml version="1.0" encoding="UTF-8"?>
<templates>
<template autoinsert="true" context="gettercomment_context"
deleted="false" description="Comment for getter method" enabled="true"
id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
name="gettercomment">
/** * @return the ${bare_field_name} */
</template>
<template autoinsert="true" context="delegatecomment_context"
deleted="false" description="Comment for delegate methods"
enabled="true"
id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
name="delegatecomment">
/** * ${tags} * ${see_to_target} */
</template></code></pre>
<br />
This is the xml with embedded stylesheet.
Without stylesheet and with tab size2, it looks like:
<pre class="source-code"><code><?xml version="1.0" encoding="UTF-8"?>
<templates>
<template autoinsert="true" context="gettercomment_context"
deleted="false" description="Comment for getter method" enabled="true"
id="org.eclipse.jdt.ui.text.codetemplates.gettercomment"
name="gettercomment">
/** * @return the ${bare_field_name} */
</template>
<template autoinsert="true" context="delegatecomment_context"
deleted="false" description="Comment for delegate methods"
enabled="true"
id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment"
name="delegatecomment">
/** * ${tags} * ${see_to_target} */
</template>
</code></pre>Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-7953000314422782212009-10-20T07:57:00.000+02:002009-10-20T14:49:59.314+02:00encrypt directoryI wanted to encrypt some personal directories I have on my laptop.<br /><br /><br />I have an encrypted directory:<br /><br /><br />jan@eee901:~/Documents$ ls /home/jan/.encrypted/<br /><br /><br />4g1Vb4HRZTsVFGXkeqcIsv3q JgpUH0yio4s6r6QuYYyNEKQVUoXKU1j937UTbHa1YOgQK, qoSuRuAL7FFdp49ZL2J9UgZp<br /><br /><br /><br />My destination directory /home/jan/Documents/encrypted is empty after a new boot.<br /><br />Now I can mount with:<br />encfs /home/jan/.encrypted /home/jan/Documents/encrypted<br /><br />an@eee901:~/Documents$ encfs /home/jan/.encrypted /home/jan/Documents/encrypted<br />EncFS Password:<br />jan@eee901:~/Documents$ ls encrypted/<br />addresses<br /><br />To umount:<br />fusermount -u /home/jan/Documents/encrypted<br /><br /><br />When you run the command for the first time, it will ask you to set password.Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0tag:blogger.com,1999:blog-16758301.post-63887543131103692652009-10-20T07:36:00.000+02:002009-10-20T07:56:46.307+02:00Using sdhc card from bootMy Eee PC 901 runs Ubuntu. I have no hard disk, but just an internal sd card, and an additional inserted sdhc card in the sd card slot.<br />I wanted to have all my /home stuff on the external card, so that in case of crash, I can just buy a new card. The internal card is more difficult to replace, so I want to use the external card for whatever possible.<br /><br />As the ext card has my /home directory, I need it to be available on boot.<br /><br />With lsusb I found the details of my card, and then added an udev rule<br /><br />jan@eee901:~/svn/hydra_test$ more /etc/udev/rules.d/01-jankester.rules<br />#ID_SERIAL_SHORT=058F63356336<br />#ID_FS_UUID=dd4cb63c-0329-4dc6-8ca8-c2e68b9d233e<br />BUS=="usb", KERNEL=="sd*", SYSFS{serial}=="058F63356336", NAME="SDHC", OPTIONS+="last_rule", RUN+="/bin/mount /dev/SDHC"<br /><br />Now I added entry in fstab:<br />/dev/SDHC /home ext3 defaults,noatime 0Jan Kesterhttp://www.blogger.com/profile/01980860348655917852noreply@blogger.com0