Showing posts with label automation. Show all posts
Showing posts with label automation. Show all posts

Thursday, December 8, 2016

SMB Client Behavior (Windows)

We do quite a bit with the SMB protocol at work, and occasionally we uncover little things that have haunted us for weeks or months. Before I jump into the interesting stuff, I want to explain what I mean by client behavior.

Client behavior is just what it sounds like. It is the behavior exhibited by a client using your application, server, service, etc. This cannot be controlled in any way since you have no presence on the system beyond the application or service used by the client. Most of the time this isn't an issue, but occasionally presents itself as a problem to solve form the server/application side.

During testing, we found that a Windows client that we used for mounting SMB shares would cache the share connection information even after the share was disconnected using something like 'net use /d.' But how did we figure this out? While getting a packet capture, we mounted a share to the Windows client, disconnected it, and then reconnected a few minutes later. The session information for the multiple mapping attempts were the same. After looking into it more, it turns out that a Windows client's Explorer.exe process will cache the connection information when shares are mapped. We have not been able to figure out when this cache is cleared, but since we use automation to perform testing, we can't afford to wait minutes or hours for the cache to clear to ensure new session information.

So, after a few talks about 'client behavior' I found a method of preventing this kind of 'convenience' from impeding our testing efforts. I present to you, the fix:

taskkill /IM explorer.exe /F; explorer.exe

Killing explorer?! Absolutely. Running this inside powershell took less than a second on the test machine and solved the unique problem.




Saturday, December 3, 2016

Setting Up Jenkins At Home


What: I'm going to walk you through setting up Jenkins on your home server.
Why: A recent phone call got me thinking. I knew how to use Jenkins pretty well, but I've never actually been through the process of setting it up on a server. Also, Jenkins is an impressive and widely used automation tool that can do all sorts of things for you, so why not set it up at home?
Environment: I'll be setting up Jenkins on a HP Microserver Gen8 running Ubuntu 14.04 LTS. With that, though some of the steps may apply to other linux distributions, it is tailored for Ubuntu 14.04.
Getting Started:
1. Install OpenJDK8 if you do not already have it installed. Ubuntu did not have the source in its software repository so an <apt-get install openjdk-8-jdk> didn't work for me. If you encounter the same, go ahead and add the webupd8team repository: (Note: The commands include everything inside the first set of "<>" brackets)
<add-apt-repository ppa:webupd8team/java>
<apt-get update>
<apt-get install oracle-java8-installer>
<apt-get install oracle-java8-set-default>
2. Next, install the Apache 2 web server.
<apt-get install apache2>
3. Finally, after you have taken care of its dependencies, it is time to install Jenkins! Only... it also isn't in the Ubuntu repository list. Worry not! We'll do the same thing we did for the OpenJDK8 repository.
<wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add ->
<sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'>
What did we do? The first command adds the repository key to "apt" package manager so Ubuntu can validate it is indeed getting the software from where it believes it is. The second step adds the Jenkins software source list to the "apt" package manager list of sources. Now "apt" knows where to find Jenkins and has a key to validate the software.
<apt-get update>
<apt-get install jenkins>
Update your package manager cache and install Jenkins. When you are ready to start configuring Jenkins, navigate to http://yourhostname:8080. You're done!
See my next post on configuring your newly deployed Jenkins server.