Posts

Multi Tenant applications using PostgreSQL Row Level Security

 PostgreSQL supports Row Level Security (RLS) so that applications can restrict who can see which records in a table either based in DB user name or based on Connection session variable. This feature can be used to implement discriminator based multi tenant where records for multiple customers are present in single table. This blog explains steps for implementation https://www.crunchydata.com/blog/row-level-security-for-tenants-in-postgres Advantage of this approach is that its easy to implement and day to day application development activities dont have to bother about breaking multi tenancy because code for applying discriminator is implemented at a framework that obtains connection from connection pool. Application developers dont have to modify individual SQL statement or even pass around tenant_id as a parameter in method calls. Good thing about RLS is that RLS policy can be applied to specific Roles in Postgres and these roles should be used by application connections wh...

How to make HTTP Server wait to read input from socket to test connection timeout

 To test HTTP server or proxy is closing HTTP connection on configured timeout when client browser or application is taking longer to send complete HTTP request. In this case, HTTP Server (tested with WildFly) waits in reading from socket. This works in case of POST request by specifying content length header but write only lesser bytes to socket than specified in content length header. Option 1: https://stackoverflow.com/a/53695968 exec 88<>/dev/tcp/192.168.1.10/8080 echo -e 'POST /api/test/ HTTP/1.1\nHost: 192.168.1.10:8080\nAccept: */*\nContent-Type: application/json\nContent-Length: 200\n\n{ "id": "100"} ] }\n\n' >&88 sed 's/<[^>]*>/ /g' <&88 Option 2: Used netcat in Linux. Note that there is a line between Content-Length: 200 and JSON. This is needed for compliance with HTTP spec. netcat -v -v 192.168.1.10 8080 POST /api/test HTTP/1.1 User-Agent: curl/7.29.0 Host: 192.168.1.10:8080 Accept: */* Content-Type: applicati...

Recovering Dell Laptop Windows OS using factory image from Linux bootable USB drive

I used Linux booted from a USB drive to restore Dell Windows 7 factory image on Inspiron 1545 when Windows 7 stopped booting and F8 key stopped working. This was done using Linux equivalent of Imagex command and used dell factory.wim file. Credits goes to - https://www.dell.com/community/Windows-General/Restore-from-dell-recovery-partition-with-Imagex-Solved/td-p/4083636 Software used 1, PuppyLinux BionicPup32 8.0 (Ubuntu Bionic 32 bit) Downloaded as ISO image from their website. It is good to use any other popular distros like Ubuntu. 2, When using PuppyLinux, download Devx package which has GCC compiler for the corresponding PuppyLinux distribution. ( http://wikka.puppylinux.com/devx ). When using a full fledged distribution, this step may not be necessary. 3, USB pen drive or any flash storage. I used SD memory card because my laptop will not boot from a pendrive. 3, unetbootin-windows-661.exe 4, Wimlib 1.13.1 - downloaded source because a binary distributio...

Communication Diagram Style

Image
Simple Communication Diagram With 3 Entities This is simple form of UML sequence diagram. Can be created using simple drawing tools like in Power Point shapes.

Solaris : Send mail with attachment

Use following command to send email with attachment in Solaris from command line uuencode logfile.zip logfile.zip | mailx -s "Mail subject" myid@company.com uuencode - Encodes file into Base64 so that it can be send as attachment with a mail. mailx - Email client available in Solaris. Use -s option to specify mail subject. This is useful for sending log files from server as attachment. This works for me in Solaris 10. It should be same for other versions also.

Selenium WebDriver : Generating IEDriverServer logs

Selenium 2 (WebDriver) uses Windows executable file IEDriverServer.exe to communicate with InternetExplorer. In the event of any issues with IEDriverServer.exe, logs should be generated for the executable. In Java one can use following code to generate log file from IEDriverServer.exe.     InternetExplorerDriverService.Builder service =         new InternetExplorerDriverService.Builder();         service = service.withLogLevel(InternetExplorerDriverLogLevel.TRACE);         service = service.withLogFile(new File("c:\\logs\\selenium.log"));         WebDriver driver = new InternetExplorerDriver(service.build()); This generates logs with log level of TRACE and is saved to file at path C:\logs\selenium.log

java.util.logging - Bad level value for property: org.openqa.level

Bad level value for property: some.package.name.level         The above error is produced by java.util.logging.LogManager when the log level is invalid. for eg. you might have specified a log level of DEBUG and DEBUG is not a valid log level in java.util.logging.         org.openqa.level=DEBUG         Valid log levels in java.util.logging are SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL, OFF     Correct usage is     org.openqa.level=FINE