DevOps Testing with Ruby RSpec Selenium and Capybara using Docker-Compose

I watched LinkedIn training “DevOps Foundations” with Carlos Nunez instructor. In section 3 he shows the use of RSpec and Capibara. I’ll extend a little bit as that section assumes a lot of things from the instructor side.

Step number 1 launches a Docker container with the Nginx web server. That is ok. Then he starts a second container which is Selenium.

Both containers use docker-compose. Nginx is launched with a Docker file. Selenium is not, instead just a raw image is downloaded.

Instructor launches a third container, which contains Rspec and Capybara. This container is specified again with a docker file

What is omitted is an explanation of Selenium, Capybara and RSpec. So let’s start.

Selenium is a web browser instance with an API tailored to be run from a container. The image used here also has a VNC server which is useful when using containers.

Capybara is a Test Framework with support to multiple languages.

RSpec is the ruby DSL.

Why we are using this combo is not explained.

Let’s see my containerfs launched with docker-compose:


Customize your terminal with Oh-my-zsh for Fedora

I have customized my Linux Terminals. Terminals I use are Terminator and Terminology. I use zsh Shell and Oh-My-Zsh framework to add some cool functionality.

For instance, a cool prompt with git integration. I see a git notification in the prompt telling me that 1 file was modified and 11 files are not tracked. It is a summary from git status.

Cool command line plus git integration.

Nice Icons showing folders and file types …

Cool icons associated to files

Tab completion. Type tab key to complete path. You can use arrow keys to navigate files and folders.

Tab completion and navigation.

Command line Fuzzy finder. Type Ctrl-r in terminal then type command to look for. You will get a list of previous commands typed before associated to search.

Type Ctrl-r then pattern. You have option to navigate with arrow keys

Plugins. The git plugin, for instance, shows me all the options for git when typing git then Tab Tab.

Git plugin shows git sub commands.

Use it with tmux!

Tmux adds nice footer

Quick steps to achieve this setup.

Install zsh

Install nerd and awesome fonts

Install oh-my-zsh

Install powerlevel10k

Install syntax highlighting and autosuggestion

install fzf then run install

More about fzf here:h


Setting up Neovim plus Coc for Python, C++, Go, Rust and javascript

There is no doubt, coding is getting more complex nowadays. I have to code in Python, C and C++ and I have usually used vi for small edits. For production I have used PyCharm, for C, C++ Visual Studio.

Visual Studio Code is a great editor with multiple extensions to support different languages. Although, I am used to vim and I always tried to setup intellisense to support different languages.

I like to use Visual Studio Code, however, I feel more productive with vi editor. In this post I’m setting up NeoVim with Coc to code in my favorite languages. In the past I tried vim with different plugins to have code completion.

Finally, I think NeoVim plus Coc is a good option to use vim.

COC requires nodejs and yarn. So, first step is to install those tools:

Install nodejs, create node repo:

curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash 

Install nodejs

sudo dnf install nodejs

Install yarn:

Create yarn repo with

[yarn]
name=Yarn Repository
baseurl=https://dl.yarnpkg.com/rpm/
enabled=1
gpgcheck=1
gpgkey=https://dl.yarnpkg.com/rpm/pubkey.gpg

Install yarn

sudo dnf install yarn

Install Vim Plug:

sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

Setup Plugin Manager in your init.vim file:

Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}

Launch NeoVim and manage code completion from inside NeoVim. This is what I like more about COC, you can install all the code completion extensions using CocInstall:

Neovim. Show Installed Coc Extensions
CocInstall coc-rust-analyzer and others....
CocInstall Output

PYTHON

Notes: Set interpreter to python 3. Optional use Jedi or language server. I’ll use Jedi:

I had to remove python3-jedi package from Fedora and install it with pip3. You can use CocConfig to setup json file and toggle jedi or language server.

Code Completion JEDI
Code Completion JEDI disabled

C++

Code completion using clangd

RUST

You need to setup Rust-Analyzer with CocConfig

GO

Code completion using gopls

SetUp Go settings with CocConfig.

My coc-settings.json:


From CocConfig

Add a network bridge to your KVM/qemu Virtual Machines.

I was used to SetUp VirtualBox Guests with a Network Bridge in order to have bidirectional access from Host to Guest or Guest to Host. In the simpler NAT mode, I was only able to ssh from my Host to Guest but not ssh from Guest to Host.

Most of the time I used the Bridge Network Mode in Virtual Box, then I switched from Virtual Box to KVM/qemu/libvirtd. Thanks to virt-manager or Gnome Boxes it was relatively easy to use those tools instead of VirtualBox.

When using virt-manager, you have the option to setup the network mode from GUI. Unfortunately there is not an option in drop box to select Network bridge. Instead we have to create the bridge from command line.

Use Network Manager Client to create “br0” bridge interface, in my case the physical Ethernet network interface (From a ThinkPad docking) is: enp0s20f0u2u1i5.

 sudo nmcli con add ifname br0 type bridge con-name br0                                                                                  
sudo nmcli con add type bridge-slave ifname enp0s20f0u2u1i5 master br0                                                                  

Bring down physical Ethernet interface and bring up bridge br0.

sudo nmcli con down "Wired connection 1"                                                                                                 
sudo nmcli connection up br0

Setup xml file to be used by virsh:

Use virsh:

sudo virsh net-define ./kvm_br0.xml                                                                                                      
sudo virsh net-start br0                                                                                                      
sudo virsh net-autostart br0                                                                                                             

You will see bridge br0 in drop box from virt-manager

My host now has IP Address 192.168.0.104

My KVM guess has IP Address 192.168.0.105. Then, thanks to bridge I can ssh from Ubuntu Guest to my Fedora Host!

You can modify bridge IP address manually as well. For instance, use:

nmcli connection modify br0 ipv4.addresses '192.168.X.X/24'
nmcli connection modify br0 ipv4.gateway '192.168.X.254'
nmcli connection modify br0 ipv4.dns '192.168.X.254'
nmcli connection modify br0 ipv4.method manual

Javascript Development for Fedora

This post will show how to install node.js and npm from github repositories. Then typescript will be installed.

First thing clone repo from node.js

git clone https://github.com/nodejs/node.git 

Then, as per instructions to build run ./configure and the make -j4

Prerequisites are python, gcc and make.

This will create node command. What is not clear is how npm is inside this distro.

node pre-release

npm is the package manager and it is only a js file run by node. This is included in node distribution,

npm client

but there is also a npm github site. What I found is that only documentation is built with npm git repository.

git clone https://github.com/npm/cli.gi

However, I used this command to install npm:

curl -L https://www.npmjs.com/install.sh | sh

Once I built node binary I copied to my ~/bin folder and then to my path.

npm uses 2 locations to set up libraries. Global and local. I’m new to node so I understood that local is project specific. In the other side, global it means only one path.

For instance, from my own build, global is set to:

Global prefix

In this prefix main modules should be installed:

npm global modules

Finally to install typescript use npm to install it. In this sample, I’m using npm from GitHub Repo. This is pointing to different global prefix.

npm from node npm_cli ..

This is weird. I think I’ll use npm version I installed with curl.

In an additional note, npm from Git repo did not work at all. I had to change npm script to fix path issue with npm_cli.js. Once I did that change npm worked:

I changed these lines from npm file:

18 ###NPM_CLI_JS="$basedir/node_modules/npm/bin/npm-cli.js"
19 NPM_CLI_JS="$basedir/npm-cli.js

Anyway, tsc is ready to run typescript files.

OAuth2 with Google CloudPlatform

I was looking for a setup to test my OAuth2 Knowledge and I found excellent videos and articles in internet. Specifically I followed this one:

OAuth2 Plain…

Now, trying to create my own test I went to my Google Cloud Platform Console and create my Oauth2 Client Id and Consent Screen. Please, note that GCP offers different options to add a Client Id. I selected the one for Web Application Client.

OAuth2 needs consent screen

Now, lets test with OAuth2 debug tool: State is not in screenshot but I set it to “anti-forgery”. See success screen.

Continuation …

And it worked!

look at

Then use code to get token. I used Postman:

JWT bearer …

Alienware Command Center AWCC not loading thermal and overclock icons.

After I upgraded my Alienware to Windows Developers Preview I noticed AWCC was not loading thermal and overclock options.

Icons not loading …

Issue is narrowed down to XTUOCDriverService. This is not able to start and it is linked to Intel Tuning Utility. The driver should be used by Alienware OC Controls for overcloking.

However after I reinstalled Intel Tuning Utility this is not fixing issue. I moved temporally these files:

I reinstalled everything even XTUOCDriverService. However issue is not fixed.

XTUOCDriverService not able to load because weird error…

I noticed this issue after I moved my laptop to Windows Insider Preview Program

I think I need to report this to Microsoft.

Create Visual Studio Code Extension

I was wondering how extensions for Visual Studio Code are created. Googling I found this.

I followed instructions there and created my first demo extension.

Step number 1 is to install with npm :

npm install -g yo generator-code

Then, generate boilerplate code

yo code

You wil see:

What to generate?

Check the dialog:

Answering setu

Then, check typescript generated code and setup in package.json

F5 to launch the extension. New instance from Visual Studio Code will open

Check the simple message on the bottom

Hello World typescript demo

You can even debug the typescript code.

Build SuperTux with vcpkg and Visual Studio Code

I watched recent You Tube video: C++ Development with Visual Studio Code with Julia Reid.

https://www.youtube.com/watch?v=WqXrYfSKJXk

In the video, Julia shows how to use Visual Studio Code to build and even debug SuperTux2 video game:

SuperTux2 https://www.supertux.org/

It was interesting how to build this nice game with Visual Studio Code. I have used it for demo samples as I have used Visual Studio Community Edition to build more complex projects.

I followed the Video and I was surprised what easy was to build and generate such game:

This is my own build:

SuperTux built with Visual Studio Code

However, it was not that clear in Julia┬┤s video how to sort out all the issues faced when trying to build SuperTux from scratch.

So, before being successful to get SuperTux running as in screenshot I had to troubleshoot.

This post details what I did to get same results that Julia.

What is assumed is that you already installed Visual Studio Code:

https://code.visualstudio.com/download

Visual Studio Build Tools:

https://visualstudio.microsoft.com/visual-cpp-build-tools/

cmake Visual Studio Extension:

CMake extension

Then you clone SuperTux repository and open the project with Visual Studio Code.

Keep in mind that you need to use –recurse option or submodule option. Look in SuperTux wiki to clone correctly repoi.

At this part the video skips a lot of explanation.

Julia explains how to set the active key to Visual Studio Tools 2019 – amd64

She also explains how to setup build variant to Cmake: Debug Ready

At this point the build config is done but if you try to follow this sequence you will see this kind of error:

Missing dependencies

This error means that all third party libraries used by SuperTux are not installed in your system. In Julia’s case, she already installed those dependencies with vcpkg. So at this point is important to mention that we need to install vcpkg!

Clone vcpkg repo from:

https://github.com/microsoft/vcpkg.git

Go to git folder and run:

bootstrap-vcpkg.bat 

to build vcpkg.exe.

Then run:

vcpkg integrate install

Note the message displayed:

Path to add to settings.json

At this point, setup cmake configuration to point cmake to vcpkg. Open cmake extension settings from Visual Studio Code and setup settings.json. Notice that path is the same that the one displayed by vcpkg integrate install.

{
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE": "C:/GitHub/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_BUILD": "ON"
},
"cmake.ctestPath": "",
"cmake.copyCompileCommands": "",
"cmake.configureOnOpen": false,
"cmake.generator": ""
}

Then, to enable tab completion:

vcpkg integrate powershell

Then install manually with vcpkg the dependencies. These are mentioned in video and also posted in INSTALL.md file:

“sdl2”, “sdl2-image”, “openal-soft”, “curl”, “libogg”, “libvorbis”, “freetype”, “glew”, “boost-date-time”, “boost-filesystem”, “boost-format”, “boost-locale”, “boost-system”, “physfs”

vcpkg install --triplet windows-64 sdl2

vcpkg will install by default 32 bits packages. By using the –triplet parameter you will install 64 bits version of packages instead of 32 bits.

Every time you install a package, click on the build gear button to generate cmake build file. You will get new error mentioning missing library/package. Once you generate successfully the build the tool will try to build SuperTux. Then you will get error that .lib files are missing

Those libs are provided by same project. Build them manually one by one. Select the target:

Select subproject or target

Then build every single target. lib files will be built.

Finally select SuperTux2 target. This will build exe file.

In my case, when trying to run or debug nothing happened. I launched manually exe file generated in build folder an error message showed that 2 dlls were not found:

squirrel.dll and sqstdlib.dll

Copy 2 dlls into build debug folder.

Finally, I wanted to try vcpkg.json manifest file support. I only found that feature included in latest roadmap:

UPDATE:

I downloaded latest version 0.6.2 from git and then I followed my own steps. I got a different error when running cmake configure. Specifically with physfs_lib package

This time was more difficult to troubleshoot this issue. At the end I commented this line (940) from CMakeLists.txt:


This was not elegant but at the end allowed me to run cmake configure.

After that, the BUILD ALL option worked correctly and I did not have to create every submodule one by one.

Hope this helps.