Friday, June 12, 2015

Setting up a new hyper-v Windows 2012 server to be pingable and allow RDP connections

At my current company we are needing to test deployments not only to Linux but Windows too.

To quickly have preconfigured systems come up we use virtualization (Hyper-V) along with other technologies like Vagrant and Ansible with other configuration and testing scripts like Python and/or Powershell.

I just setup a new Windows 2012 R2 Machine in Hyper-V using a ISO image.

By default, some features aren't enabled to make my testing easier. For example, to be able to ping the machine or RDP into it for GUI related tasks.

To enable Windows to respond to a ping you have to go into Windows Firewall with Advanced Security > Inbound Rules and enable File and Printer Sharing (Echo Request - ICMPv4-In) by right clicking on the rule name.

For remote desktop connections I had to do two things:

1) Type SystemPropertiesRemote and select "Allow remote connections to this computer."  I also deselected the "Allow connections only..." beneath it
2) I ran this command: netsh advfirewall firewall set rule group="Remote Desktop" new enable=yes

If for some reason I disabled Allow remote connections again I would have to do the two steps again to get RDP to allow my remote client to connect.

Friday, May 08, 2015

Caveats/setup notes for running pytest with Jenkins on Windows 2012 R2 server

I've been writing test code in Python for the last few weeks.  Although it's been great to have Perl and Java as my predominant testing languages, it is nice to try a new scripting language on for size.

I first used Python on Linux and this last week - due to testing requirements - I needed to use it on Windows.

Python Installation :

Installing Python is pretty straightforward. Go to python.org. and download it. Installation is very easy.

After the install, I needed to add the Python to the System Path.

Pip and Pytest Installation :

Pip seemed a little different to install -vs- Linux. With Linux I could install with yum and call pip directly. To use Pip on Windows I had to call it through Python first

Installing Pytest then required me calling Python to call pip and then install PyTest. See below:

python -m pip install pytest

With Pytest installed I needed to incorporate it into my Python test class:

1) Import PyTest in the Python script using : import pytest.
2) Use an assert statement for test results.
3) Place the test statements in a test method (def testSomething(): )  For the tests to work correctly with JUnit output I needed to put the asserts in a test method.
4) Create JUnit output for Jenkins. When I did run my basic test class without outputting to an XML file it seemed to work just fine, but if I wanted to get results to Jenkins I needed to get an XML file for Jenkins to read.
5) Once I solved the above issues I needed to make sure a JUnit XML file was created. This is how I called it below:

python -m pytest scripts\CheckMSIBuildStatus.py --junitxml=results.xml

Tuesday, May 05, 2015

Running a java test class in a maven project on the command line

Sometimes I need to write a quick one-off Java test class against a developer's maven project or class within a maven project.

Easy to do locally on my Mac but my Mac is not a production environment.

In this case this necessitates that I run this test class on a remote machine (UNIX or Windows) where I'd rather not setup a full development environment and most likely have command line access.

Given a minimal production environment the requirements are : I can compile the developer's class, supporting classes and libraries, my test class, and then test the resulting service; in this case a small micro service the developer created.

Pre-requisites, in my case, needed on the remote machine are :

1) Java
2) GIT
3) Maven
4) If needed, the service deployed and running under systemd. 

Once I have the first three components installed, I clone the GIT repository and then try to build the maven project, usually with a mvn clean install -Dmaven.test.skip=true.

If I have any dependencies to this project, I try to use a library manager referenced in a settings.xml file under .m2 (like Artifactory) to make the project compile.

If this succeeds, I try to compile my stand-alone test class. Since I'd rather not run the developer's unit integration tests I run this command :

mvn install -DskipTests

This allows my class to compile. If this works I then I run this command :

mvn exec:java -Dexec.mainClass="com.[path to my test class].[my test class name]" -Dexec.classpathScope=test -e

Running this command allowed me to launch the Java driver program that then - in this case - created a new instance of the developer's monitor class that would run in it's own Thread through Runnable, which I could subsequently test.


Monday, April 13, 2015

GIT : getting the lastest changes from your upstream master when you have no changes in your repo

I clone a lot of our micro service repositories locally into my own branch, but then really don't add to them. A few months pass and then I need to re-sync.

GIT seems to make it a little harder to do it compared, to say, Perforce, another source control program. At a high level you have to get the latest changes from your upstream master, that you forked from earlier, fetch and then merge.

I've detailed the more individual steps below, and what I encountered. To start, you may not even have your upstream master defined!

Here are the high level command line steps I took on my Mac Book Pro.

git fetch upstream

   I got > fatal: 'upstream' does not appear to be a git repository. So here upstream is not defined.

git remote -v

   With this command I noted that no upstream was listed. Guess I have to create it then.

git remote add upstream http://github[remainder of URI path]/[repository name].git

   This command allowed me to define my upstream 

git remote -v

   Verification step that upstream remote was now defined

git fetch upstream

   This got me the latest changes, but stored it locally in a repo called upstream/master.

git log

   This verified that the latest changes - in my local master repo - were still from a few months ago so a couple more steps needed.

git checkout master

   Although not needed in my case, just a verification I was on the right branch. This command will move you to the master branch in case you might be on another branch.

git merge upstream/master

   This command finally synced my local unchanged branch to the latest changes in the HEAD, aka upstream.

git log

   With git log I saw the latest changes were from today.


Hope this helps.

Sunday, February 15, 2015

Pad Kee Mao Gai

I created a separate cooking blog...

The blog writeup will move permanently here >

http://andresfernandezcooking.blogspot.com/


*************



I've been cooking Thai cuisine the last 2 years and have learned quite a few dishes.

I've done Lad Na, Pad Thai, Masaman, Pad Prik Khing, and other recipes, but wanted to try something new with Thai basil.

I order a lot from importfood.com, and wanted to use their recipe on the website but did a little more searching to see what the recipe would look like and see the possible variations.

I tried this recipe here : Alosha's Kitchen and with a couple of small modifications, I thought it was a very good recipe.

To keep the heat down to medium, I used only three Thai chilies along with 12 ounces of wide noodles and a pound of chicken. I did use a whole small red onion and a red and yellow pepper; so twice the amount of onion.

If you're using 12 ounces of wide noodles I would recommend a 1/4 cup of fish sauce, slightly a little less of the golden mountain and thick soy sauce and directly mix it with the chicken before putting it in the pan. I also mix my palm sugar with water for easy use and store it in the fridge so I can just pour it on the dish as I'm creating it.

Here's a photo of the finished dish :


Wednesday, February 11, 2015

Comparing UNIX networking commands : netstat, lsof and ss

I've realized recently there's a lot more availability in UNIX commands to look at your network (open ports, etc...).

Some sample commands that do the same thing, which I'll investigate later :


netstat -a -p  | grep 13100

ss -all | grep 13100

lsof -n -i4TCP | grep 13100

These three commands do a lot of similar things, albeit with some minor tweaks; and then pipe it to grep to look at a specific port.

Currently, my favorite for information and formatting is lsof.

I'll write more later...

Monday, February 09, 2015

The simplest resolution or explanation is usually the most common solution

In engineering, we have to diagnose and fix issues all the time.

In my case I've found that the problems I encounter when I find a build broken, a class that won't compile, or a problematic configuration that won't make a application run, is most likely due to a slight misconfiguration, misspelling, or not reading the directions thoroughly.

In other words, the easiest solution is usually the most common fix to a problem you've encountered.

Maybe this is why we have Occam's Razor as a principle?

Sunday, January 18, 2015

Quick iptables setup to close off an outgoing IP for testing network interruption scenarios

I think for a lot of software testers these days, we have to test systems that span multiple servers.

Whether it's JGroups, 0MQ, or other messaging protocols, you have to make sure that systems behave correctly - or fail gracefully - when connections go down.

I posted about iptables before but it's good to review a couple of simple steps.

If I'm on a Linux system (like CentOS) I can test how a certain application might behave once it cannot connect to an external server.

If it's a simple system setup where you're testing just one application connection to another external application it's as easy as :

iptables -A OUTPUT -d [ip address] -j DROP

-A OUTPUT means to append to the OUTPUT chain (from this server to an external server)

-d is for the destination IP you want to block

-j is for jump target. If a packet matches what was stated for -A and -d then what should iptables do? In this case, I'm adding this packet to the DROP chain.

and...when I'm done testing and need to reenable communication to that IP,

iptables -F

Exploring ELK (Elastic) Stack for hack-a-thon

At my current gig, our group finally got to do hack-a-thon week and I joined a team project that tied together a few of the technologies I&#...