Testing in Production

This is a topic that always draws some great responses when discussed where I work. Do you Test on your production systems?

I always come to the same conclusion on this one. Why wouldn’t you want to test in production? I know, I know. Your system is too “special” or “secure” or “regulated” or whatever to be able to test in production. So what are you going to do? Let your customers test it for you? Throw the code over the wall to the people that matter most and hope that it works for them? Take the chance that your customer will just understand when the house of cards comes crashing down in a burning heap of lame?

To those that say it just can’t be done, I say that maybe your system is just lacking testability – you haven’t built it right. To me a testable system is one that has a great handle on control and is inherently observable. If you can’t control and observe the software, you are dead out of the gate. Often, if you solve the control and observation issue, you will find a system that you can test in production – because you engineered it to be easy to do so in any environment.

So take a look at your systems and ask yourself if there are any measures you can take to affect the testability of your system in a way that would lead you to be able to test your system in production. Face it, no matter how you try, your QA systems will never be the same as your production systems. The data, traffic, configurations, scale, timing, etc. will just never match well enough that the tests you run in those environments will catch everything. Change control, make it observable and make sure your system works in production before your customer does it for you!

Centralized vs. Federated Integration Test in the Enterprise

I have been working on the question of federated vs. centralized integration test practices in the enterprise lately. As I have done some research into the topic, I have found that few resources are around on the topic. While some white papers exist, it appears that most companies are in the federated camp: relying on individual divisions to create their own integration test strategies – even when there are many ties among their applications that could benefit from a centralized approach.

Some companies like Google have extremely large tests that involve many applications, and even automate them to some extent. Most though, including the ones that I have worked for, spend time testing software from within their respective silos in an effort to protect their own. Each of these groups tend to create and maintain redundant sets of tests that cover their application needs.

The problem is that many of these needs are the needs of many of the other groups and a great deal of redundant and poorly performing tests are written. Every group creates a test to “create a user and password” for instance. Each is created in their silo and when the functionality changes, each breaks in their own way. Tests that perform things as trivial as this, and of course much more elaborate are created all of the time that could be shared.

Creating a centralized integration test group may be able to fix this redundancy issue and help protect production quality as you do so. Sharing resources, test data management, and testing know how might be a way to create a group that solves the issue of poor communication across your organization when it comes to system integration test. This one set of testers will help build the “moat” that protects your production castle from impending doom.

Samsung Galaxy Nexus 4.0.4 to 4.1.1 Status 7 “Assert Maguro” Error Fix

I was excited to see that the Android 4.1.1 Update for my Samsung Galaxy Nexus GSM/HSPD+ device (Standard GSM device from the Google Play Store) was out and downloaded the files from Google for the upgrade. I hadn’t unlocked the bootloader on the phone yet, so I did that and went ahead and rooted it as well using the Galaxy Nexus Toolkit. That process went well (I was pretty happy even with the push-button ease as it rebooted and applied the appropriate unlock, patch, and Clockwork Mod Recovery).

I copied the appropriate “takju” update file to the device root (mine was the JRO03C to IMM76I Linky-Link Here) and rebooted into recovery. When I went to apply the update file though I received the following error:

assert failed: getprop(“ro.product.device”) == “maguro” I I get prop
(“ro.build.product”) == “maguro” >  “Status 7” error

What???? No Jelly Bean for me??? After I stopped crying and started an hour of Googling the issue I found some possible culprits:

1. You have a non-stock ROM applied

2. The ClockworkMod Version you have flashed to your device is incorrect

Well, the first one does not apply – Mine is stock all the way. But the second one is interesting. Turns out, when you use (at least the version that was out there today) the Nexus Toolkit to apply the Clockwork Mod Recovery, when you choose GSM, is the wrong version.  The Toolkit installs the 5.5.04 version, which is for CDMA, but should have installed 5.5.02 which is correct for the GSM version. To fix this, I simply installed ROM Manager on the phone from the Google Play Store and flashed the correct Clockwork Mod Recovery version to the phone (if you choose Nexus GSM it chooses the correct one for you.) Then a quick reboot into recovery, apply update from SD, and reboot. Then you have your wonderful Jelly Bean!

Here is the link to the Toolkit – It’s pretty awesome, even though it steered me wrong on the Clockwork Mod version.

Hope this helps others with the same problem!

Android Emulator 4.x API 16 Keyboard Issue

I was working on an android issue today where I wanted to use an emulator with no keyboard present. I tried creating a few different versions using API Level 16 4.0.3, and could get no keyboard present by editing the AVD in the Android Virtual Device Manager. After several attempts (and hey, this thing starts so darn fast each time you edit it) I was ready to quit trying. In other versions the on screen keyboard is launched when you tap the EditText, but for some reason all I would get in the latest emulator is the “Select Input Method” notification in the shade… not a keyboard even if I messed with the input settings.

Turns out the key is to add the Keyboard support = No to your AVD and then when you launch it, choose wipe user data. Ah, secret incantation that now exists that didn’t before! Thanks!

LG Tone HBS-700 Wireless Stereo Headset

OK, I have piles of headphones, Bluetooth, wired, earbuds, over the ear cans, and the junk ones from Apple. This week I felt it was time to explore the bluetooth realm again and started looking around for a new set. I have had a couple of Motorola units in the past – the S305 which are just OK – sort of bulky and awkward to wear, but with decent sound. The other Moto set I tried was the S10-HD “Rokr”, and this was complete junk. Don’t sweat while you work out or POW! You now own a $70 hunk of plastic. Many people have had the same issue – don’t go here.

So I found the HBS-700 on Amazon, from LG – a company I have been impressed with lately with other products. The review was pretty good, so I pulled the trigger and ordered a set. When the package came, I read through the packaging and was happy to see it even said “water resistant” – guess they did some research and it turns out, people work out with headphones on.

Setup was a breeze, it connected to my Samsung Nexus S Android phone in seconds without a pass, and I was ready to go. The sound is great, no hiss, and really nicely isolated with the ear-buds – which is a odd thing about this headset. The HBS-700 main device hangs around your neck, and wired, normal ear-buds are strung from it to your ears. At first I was leery that this setup would be good, but surprisingly it is the best I’ve had in a headphone solution. The best part of the head set is that there are no wires from your neck to your waist, where wired sets always get in the way. You hardly notice the unit around your neck, and you can easily run without them really being noticed.

The battery charges quickly, and I wore the unit for about 8 hours before I charged it, and the package says 10 hours listen/talk time. Call quality is great, the neck unit vibrates when a call comes in – which is nice if you don’t have the earbuds in. You can store the ear-buds in the end of the neck unit with their built-in magnets, which seems nice but the 6 inches of wire in the area for each bud still seems like it might catch on things, but has been pretty good so far in my week trial.

The controls are great with volume, FF, RW, Pause/Play and a phone button that brings up the voice recognition system for actions like “call Lisa Smith”. The power button is small and in a strange spot on the side, and after a week I still have to take it off and search for it. The device supports Bluetooth version 2.1+EDR (A2DP/AVRCP) and comes with a one year warranty.

I really like this headset, and would recommend it to anyone looking for a good Bluetooth solution for their mobile device. The Android market even has a app called “BT Reader” that works with LG devices and reads your text messages to you when they arrive – still testing this out to see if it is as decent solution, but not expecting much – it doesn’t turn down the music as it reads them, and crashes now and then. Also, you have to manually press a button on the screen for it to read it – so not terribly impressed with it.

 

Android Shared Preferences Backed Up

I have been looking around for some way to back up the preferences in my Android app – just a simple serialization of the SharedPreferences object. Here are some code snips from my backup object that allowed me to get the job done:

private void importSharedPreferences()
{
  SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0);
  File myPath = new File(EXPORT_FILE_PATH);
  File myFile = new File(myPath, PREFS_FILE_NAME);
  if(myFile.exists())
	{
		BufferedReader i = new BufferedReader(new InputStreamReader(new FileInputStream(EXPORT_FILE_PATH + PREFS_FILE_NAME), "UTF8"));
		String line;

		while ((line = i.readLine()) != null)
		{
				String[] pair = line.split(":");

				SharedPreferences.Editor prefEdit = prefs.edit();

				if(pair[2].indexOf("Boolean")>-1)
				{
					prefEdit.putBoolean(pair[0], Boolean.parseBoolean(pair[1]));
				}
				else if(pair[2].indexOf("Integer")>-1)
				{
					prefEdit.putInt(pair[0], Integer.parseInt(pair[1]));
				}
				else if(pair[2].indexOf("Float")>-1)
				{
					prefEdit.putFloat(pair[0], Float.parseFloat(pair[1]));
				}
				else if(pair[2].indexOf("Long")>-1)
				{
					prefEdit.putLong(pair[0], Long.parseLong(pair[1]));
				}
				else if(pair[2].indexOf("String")>-1)
				{
					prefEdit.putString(pair[0], pair[1]);
				}

				prefEdit.commit();
			}
	}
}
public void exportSharedPreferences()
{
    SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0);

    File myPath = new File(EXPORT_FILE_PATH);
    File myFile = new File(myPath, PREFS_FILE_NAME);

    FileWriter fw = new FileWriter(myFile);
    PrintWriter pw = new PrintWriter(fw);

    Map<String,?> prefsMap = prefs.getAll();

    for(Map.Entry<String,?> entry : prefsMap.entrySet())
    {
    		pw.println(entry.getKey() + ":" + entry.getValue().toString() + ":" + entry.getValue().getClass());
    }

    pw.close();
    fw.close();
}

I removed all of the error handling and might have messed up the formatting a bit, but you get the idea. Also, I plan on moving the serialization to a XML format in the next few days instead of the janky colon-separated bit. Hope this is helpful to you!

Listing the Groups for a User or Users of a Group in a Windows Domain

Had to look this one up today, as I can’t remember the last time I needed this, but finding out what users are part of a Windows group, or what groups a user belongs to comes in pretty handy now and then. Here is the command prompt code:

 

To list of groups for which a user belongs:

        net user jsmith /domain

To list of members of a group:

        net group some-user-group /domain

 

Switching From Vonage to Google Voice For Free Home Phone

So I have a big Comcast internet pipe, so I thought there just has to be a way to get home phone service for less than Vonage, which is close to $30 a month. I took a look around and found a solution that while a little dicey, got me where I wanted to be – home phones that ring for free AND using my original land line (well now Vonage) number.

The steps to port started with a trip to Wal-Mart, where I purchased a T-Mobile “Monthly” phone for $20 (monthly is their new word for pre-paid – which is what I was after.) I have read that you can do this for even cheaper by popping into a T-Mo shop and picking up an even less expensive SIM and use it in an existing phone. I’m guessing that you can do this on any wireless carrier.

My final goal is to get my land number ported to Google Voice. Google lets you port numbers in, but only mobile numbers – this is why I have this cheap little phone with it’s 10 minutes of built it call time. This is where the leap of faith comes in. To activate the mobile phone I called T-Mo’s activation line and was pretty quickly asked via automated menu if I wanted to port an existing number. This threw me to a human and I asked them to port my Vonage number to the prepaid phone. They said it would take 24 hours. 30 hours later, nothing had happened, so I called T-Mo and they said I would need to call during normal business hours. Great – I have a feeling this is going to be painful.

The next day I called again (I had asked for a direct # to the porting department the night before) where they looked up the port, and said “oh, it’s almost done, hold on – O.K. it’s done.” Suspicious, I hung up and called the land line number, and sure enough the plastic little phone rang! Next I called Vonage and cancelled the account – a pretty nice feeling. Step one was complete.

Next I needed to port to Google, so I logged into Google Voice and clicked the “gear” and clicked on “Voice Settings” where I found the port a number button. When you click this, Google goes out to find out if the number is mobile (which it had just become 😉  ) and reported back that it was able to do the port. Next up is another $20 as that is what Google charges for the port, followed by a bevy of “Are you sure???” questions, warnings, and statements. When I got to the end, it said the port should complete within 24 hours.

About 26 hours later I got an email saying the port was complete! Nice! Step 2 complete. Next I wanted to get a rug to tie this room together – make the phone lines ring when my Google Voice number is called. I hopped on Amazon and picked up an Obi110 device – Voice Service Bridge and Telephone Adapter for about $50. When the device came, I replaced the Vonage device with the OBI110 and logged into their site and registered it. Their instructions had you check the Google Chat box back in your Google Voice settings ( had missed this the first time through). After I got a completed setup with OBI, I picked up my cell phone, dialed my good ‘ol land line and shazam! Phones ring all over the house just like they had at the beginning of the week – only now for FREE (well $90 later I have free phone service.)

My wife says the quality is better than Vonage, and I have to agree. There are some considerations using this setup – 911 calls are not automatically routed. But this was going to be the case if we had decided to jut go Cell anyway. Google Voice may not be free forever. I’m guessing they stay free, but I can cross that bridge later if need be. There are other low cost alternatives to hosting your Voip number, so maybe a port to them would be a fix for that.

Netflix vs. Amazon Prime Instant Video

Netflix is about to get pretty expensive on 9/1/2011 and I’ve been searching for some alternatives and Amazon Prime is back in the picture.

Amazon Prime Instant Video has seamless Xbox extender integration that allows you to play movies instantly on the Xbox. Just tried it. Movie was 2% downloaded, and it said ready to watch. Walked to living room, started Xbox and was watching a high quality (no variable rate Netflix stutter or mice teeth) a minute later. The only install was a Amazon Unbox service that runs on the PC that automatically starts downloading anything you order (which is free with prime) even when the order comes from another device – say your mobile. Amazon quality is roughly similar to a DVD (when taking into account their advanced encoding vs. DVD – so a tie with Netflix DVD’s at home) and certainly better than some of those lower Netflix streaming rates for instant.

I have a pretty heavy Netflix account (3 d’s at a time) that goes to over $25/mo in September. Even if I put the Netflix account on hold for 3 months and “get by” with Prime, it pays for Prime for the year. One thing that complicates that though is a couple of kids in College that are using Netflix, and Prime extended family members only receive shipping benefits – not video. Sticking with the Netflix account but dropping to the $8 streaming only version may be the way to go there.

What about selection? Prime is currently saying 6000 instant videos available, and Netflix says 70,000. OK, that one certainly goes to Netflix. But I took a look at what I have watched recently and found that most of it was available on Prime, but the obscure stuff only on Netflix.

So, it looks like I’m going to have to switch in the next few weeks, Amazon Prime has my vote. I can live with the selection loss while a Netflix reduction happily pays for my Prime account chock full of 2 day shipping and free video.

Exporting MS SQL Schema

I seem to forget this one, though I have to do it now and then, so I thought I would share this in a post. Somehow I always find myself digging into “Script Database As” instead of the much less appropriately named “Tasks” – which is where you want to be. If you want to export the schema of your MS SQL database, here is what you do:

  1. Open the Microsoft SQL Server Management Studio, and connect to the database
  2. Expand the Databases node, and right click on the database you want to export the schema for
  3. Choose “Tasks” (in 2005 “All Tasks”) then “Generate Scripts”
  4. Navigate through the wizard choosing your database
  5. You can choose “Script all objects in the selected database” on the “Select Database” page, or hit next and choose the individual objects on the following screens like Options, Schema, Tables, and Users
  6. Finally you will find the schema and tables to select
  7. On the last page of the wizard you can choose to output the schema to file, clipboard or to a new query window

Hope you find that useful!