Skip to main content

Posts

Push image to Docker https registry

 Setup remote https registry docker container stop registry docker container rm -v registry ls /var/lib/ cd mkdir certs cd certs openssl req   -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key   -addext "subjectAltName = DNS:myregistry.jankester.com"   -x509 -days 365 -out certs/domain.crt cd .. openssl req   -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key   -addext "subjectAltName = DNS:myregistry.jankester.com"   -x509 -days 365 -out certs/domain.crt ls -ltr ls cd certificate_authority history | grep import ls -ltr ../ ls -ltr ../certs cd 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 docker container ls history | grep allow sudo ufw allow 5443 docker images ls curl -X GET http://localhost:5000/v2/_catalogs curl -X GET https://localhost:443/v2/_cat
Recent posts

Certbot https certificate

 Install https certificate for apache sudo apt install certbot python3-certbot-apache cd /etc/apache2/sites-available/ ls sudo cp 000-default.conf jankester-com.conf sudo vi jankester-com.conf sudo a2ensite jankester-com.conf sudo a2dissite 000-default.conf sudo apache2ctl configtest cd /var/www/ ls ls -l sudo mkdir jankester-com sudo mkdir jankester-com/public_html sudo cp html/* jankester-com/public_html/. sudo apache2ctl configtest sudo systemctl restart apache2 sudo ufw status sudo certbot --apache sudo apt-get install certbot python-certbot-apache sudo apt-get install certbot python3-certbot-apache sudo certbot --apache sudo apt install certbot python3-certbot-apache certbot --version sudo apt install snapd sudo snap install --classic certbot /snap/bin/certbot --version sudo /snap/bin/certbot --apache cd jankester-com/public_html/

Install tileserver

Install Postgis  sudo apt-get install -y postgresql postgis sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts sudo service postgresql start locale git --version # to verify whether git is already installed sudo apt-get install -y git sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts sudo service postgresql start echo $USER locale -c locale createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0 sudo -u postgres createuser -s $USER createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0 psql -d gis -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;' psql -d gis -c "create user jan;grant all privileges on database gis to postgres;" psql -d gis -c "grant all privileges on database gis to postgres;" psql -d g

Create a groovy console and bind to selenium

Required groovy files 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. ConsoleWaiter.groovy The idea of Groovy Console I found on some other sides. Honour goes for instance too: http://josefbetancourt.wordpress.com/tag/eclipse-2/ I copied some code of this, and put it under src/test/groovy/com/jankester/selenium/test/utils: 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.

Setting up maven project to do first interactive test

The pom file A basic pom file that sets up all dependencies for your interactive selenium-groovy testing contains following: <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>

Interactive selenium testing

The problem Location of elements 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. Junit testcase With this information I could then create my junit testcase: @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 su

Logging in selenium

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. 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. This is the approach I ended up with. 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,

Junit4 running parallel junit classes

To run junit testcases parallel, you can create your own class to run junit with: Add this tag to your class declaration. @RunWith(Parallelized.class) Implementation of this class looks like: package mypackage; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.runners.Parameterized; import org.junit.runners.model.RunnerScheduler; public class Parallelized extends Parameterized {         private static class ThreadPoolScheduler implements RunnerScheduler     {         private ExecutorService executor;                 public ThreadPoolScheduler()         {             String threads = System.getProperty("junit.parallel.threads", "16");             int numThreads = Integer.parseInt(threads);             executor = Executors.newFixedThreadPool(numThreads);         }                 public void finished()         {             executor.shutdown();             try            

Run jmeter from eclipse

Download jmeter source and binaries: http://archive.apache.org/dist/jakarta/jmeter/binaries/jakarta-jmeter-2.3.4.zip http://archive.apache.org/dist/jakarta/jmeter/source/jakarta-jmeter-2.3.4_src.zip Unpack jmeter source file, and rename eclipse.classpath into .classpath. Add a .project file to the same directory: <?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> Now import the source code as eclipse project. Add all libs of binary distribution (lib/*.jar) to the new project's lib dir.

Debugging against jmeter

Inside jmeter startup script, add: 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% Now start jmeter. It will hang and wait for debugger. In eclipse, add a new remote java application debug configuration. Add jmeter source code to it. Connect. Jmeter will start now. Attach jmeter source code. Lookup class: org.apache.jmeter.engine.StandardJMeterEngine Set debug point in runTest() method and start your script.