Monday, 14 May 2018

A Python strangle hold

Having a look at a piece of work I built for client reflectively. I noticed that I had early on opted for a bottom-up approach to an implementation where I control a remote machine.

Bottom up is not a design Pattern

I said to myself that it was wrong to have gone that way about it, because bottom up meant starting from a windows mobile API and then wrapping it in Powershell, and then wrapping that in a Python unittest. In balance it's a bit light on Python which means anyone reading or maintaining needs to learn a lot of Powershell. The powershell scripting is managing a remote connection session across test steps. This balance is a side effect of bottom-up.

Python script ~ 300 lines
Powershell script > 500 lines
Mobile API ~ 10 lines <= where all the work happens

If I had written it from top-down and written around 500 lines of Python, it would have shifted the balance but left us with around 200 lines of Powershell and a large performance hit per step in the test because the Python code cannot cache the Mobile API remote session connections. Every test probe or prod, would be a round trip and would need a new connection. My biggest regret is not sticking to my guns and moving more code to the Powershell side because it's easier to manually run pieces of Powershell as scriptlets when manually verifying. You could probably run python functions in the Python console/ide as manual steps too, but I need to stick to my expertise more often in future. Anyway, the Python code balance is annoying because maintainers do have to learn 2 languages. Top down would have been easier to maintain by nature.

Strangle Hold

I am enjoying the Python learning, which was part of the reason for my bottom-up by starting in Powershell, and learning the Python language all over again in the background while I worked my way up. I could not have commanded the Python well enough to start there I suspect. Quite happy with the outcome in terms of the refreshing of my very stale and super-basic Python. But would do it the other way if I did a similar project again.
Wierdest thing is that Python seems to be language lawyer territory in terms of style far more than in terms of looks than for example C code is lawyered over, where performance is 50% of the game. Snakebite on the other hand is 50% of the Python game. By snakebite I mean pretty pythonic code. A lot of time is spent making code look like it is pretty. Python actually has keywords and syntax (above and beyond the indentation rule) to help you make the code pretty. A pity because the excellent pylint tool is actually two tools in one, style and grammar, and because pylint parses the code and the references or lack of usage, which you don't want often. And so I find myself disabling some of the pylint warnings that are not so much about code prettiness, but rather syntactic rules, which should have been totally separated in the debate. I want my code to compile, before I want it to look like it wants to be eaten!

Thursday, 23 November 2017

ffmpeg animated gif one-liner

Commandline to make a quick demo easy and to just by default make it autoplay in for example facebook. sorry if you have seen this all before, but this blog is my braindump.

.\bin\ffmpeg.exe -i .\cbc.wmv -b:v 50k -r 2 -y -ss 2.000 -t 11.000 .\cbc_T.gif

-r 2 = 2 frames per second
-b:v 50k = 50kbits bitrate need to add the k, and need to be specific that the rate is a video rate with :v
The bitrate did not have a significant impact on file size.
-ss = start from
-t = duration to convert

Hope this helps the next person. note, there are loads of similar blog posts, but had to capture some of the more salient parameters, because ffmpeg command parser often just ignores a parameter it cannot parse, so beware typos.

Joining clips

To join 2 clips -is a bit problematic in windows because the ffmpeg separator | character has a special meaning in dos, so I found the easiest was to create a response file.

file y:\20171122_173829.mp4
file y:\20171122_170515.mp4
file y:\20171122_173829.mp4

Save this text as files.txt (note that this file expects the path separator "/" not "\" , for some reason the [drive:\] protocol is fine with a "\", but paths must use a "/".

and then use the concat argument

C:\Tools\ffmpeg\bin>ffmpeg.exe -f concat -i .\files.txt -an -c copy -y .\20171122_173829all.mp4

notice use of -an to kill the audio track off

Add Audio

Lastly, to add and use an audio track using -shortest
ffmpeg.exe -i .\20171122_173829all.mp4 -i elevatormusak.mp3 -c copy -shortest -y .\20171122_173829final.mp4

Wednesday, 1 November 2017

ffmpeg file compress

I really easy trick to shrinking files by reducing them from 30fps to 10fps

..\bin\ffmpeg.exe -i .\largerfile.mp4 -r 10 -y .\destination.mp4

I'm getting about 20x reduction in filesize - and resulting vidoe is very "skippy", but fine for desktop shared recordings that don't animate.

Monday, 23 October 2017

Which Test Cases to Automate

I've decided to blog a bit about my day-job, well, my career and passion really. Software testing, but the kind that makes sense, automated regression. But first and foremost a warning, when a computer validates some software, that's not called testing at all, it's called checking. See here for a bit more on why.

With that out of the way, lets move on. Automating anything is expensive, automating a test case is not a silver bullet, because a computer cannot validate things like a UI layout making sense, or even an API function call rejecting a parameter value either for that matter. Sure we get frameworks that test for UI changes in web pages and in WPF and other forms based applications. But when controls move and we all know that a UI changes cosmetically very often, that incurs maintenance cost. Tools exist to reduce that cost , but they only do so in very specific ways.

Likewise for Automation or Test tooling against public APIs. "Apps" on the internet are the main case here, but this also applies to locally consumed API's not just the web, and all the new kinds of web services available today, its a crazy farm almost. Just about everyone has a web service these days, or at least an API; and since that surface is the really high value customer interface, it's the best place to do testing and best place to automate at the same time. A test script using an API cannot just validate assertions in your test spec, without some skill in writing that script to be maintainable or scale well. Without going into design stasis, arguments about specs, or test frameworks, let's be really Agile; do the parts of the job we can get most early value from first and foremost.

But which test cases do you convert? From that huge batch of analysis done when you looked at this from a manual test perspective last year. The boss wants you to automate all of the things. Now.
Based on my inputs and the way we started doing this, one of the grads came up with using Excel. I'll link the sheet below, but first I'll explain what all of the columns mean.
Test ID A unique test identifier (optional) A pretty basic thing, but very much dependant on your test management tool choices.
Name Description of the test - short is better
Easy to script How easy is it to write a test script for this case. Be pragmatic in your estimate. Give it a 5 if it's trivial , but if it's impossible to, give a 0 (zero)
Manual time cost The amount of interactive human being time it takes to run this test manually, if the test suite has got lots of setup required, count that time separately, only count time for this test in hours needed. If tests tend to take a few seconds to run manually, adjust this accordingly so that quick tests get a 1 and painfully long to run tests get a 5. Also do not count waiting time, if for a file to copy that perhaps takes 30 minutes, that time is not counted.
Data/Table driven Is this a test that really benefits from boundary testing and has multiple simple input output classes that take time to cover most of the meaningful combinations fully if done manually. If Yes, give it a 5 , not really, give it a 1.
Cost of Failure Will it hurt the product and crate risk if this test fails. If Yes, give it a 5 , not really, give it a 1.
Likely to regress Is this case likely to catch useful regressions caused by code or integration changes? If Yes, give it a 5 , not really, give it a 1.
ReUse Is automating this a test now, going to help you write other tests by providing a library of helper functions that will grow your coverage eventually? If Yes, give it a 5 , not really, give it a 1.
Priority Does this verify anything a manual tester would have to do anyway before most other testing commences. Do testers test this functionality very often? In other words, is this a test that has to run early in the cycle. If Yes, give it a 5 , not really, give it a 1.
Some things to notice here, I use a very low resolution scale of 1-5. Higher granularity in the question scales actually end up take much longer on average for a user to guess at a value, and let's face it, this is a game of educated guesses or estimates anyway. It's best if 2 people do this process together. Some of the columns only benefit from entering a 1 or a 5 and nothing in between, some of the columns even allow a 0. As a tester, I'd not expect you not to try entering a 0 in cases where it makes sense to, for these, the sheet will give still you a good answer out. So you can just add these all up, or give each question priorities. In another posting, I'll share the spreadsheet template and the weightings as well.

This only works well after you have obviously captured half a dozen cases and looked at them in relation. Remember, don't spend too much time on each row, this is a planning activity only.

Wednesday, 27 September 2017

Lean Coffee Meetup

A "Lean Coffee" under the Meetup banner is an agile interpretation of a networking event for software testing professionals in our case. Because time is precious the monthly morning coffee is a very intense and quick-fire format. Final moments close with a summary where everyone states one thing they learned. Results here may vary, and I made notes only for our table which was half of the 12 or 13 odd who attended. A voted Q&A format with 8 minutes per topic presented the following ideas.

  • How to develop new testers. Getting up to speed suggestions. 
(Test mentoring, timeboxing, domain learning and process learning discussed)
  • Is the programming language used to write automated tests important?
(pros and cons for Java,Ruby,Python and importance of test fixtures were covered. As well as scale-ability and performance)
  • In a one man test team, how do you plan?
(3 amigos, division of responsibility, assesment of the security risk, assesment of scale risk)
  • How to get others to see your side of a test failure?
(describe the risk to business and cost clearly)
  • Biggest challenge in test 
(horror stories ensued)

In the meet I mentioned a link to this clip to share with people

If you want to join up with us, please follow this link and sign up.

Thursday, 17 August 2017

Maxim DS onewire temp sensor home automation

Trying to create a hybrid Raspberry pi homebaked cheapie.

1. hookup to the solar heating water system (see prior blog article)
2. Add a power consumption sensor to monitor electricity use.
3. Add water temp and room temp sensors using 1wire dallas sensors

Starting from the bottom.

A cheaper display here

  • Next up is the power. I have a standalone wireless monitor, which is technically on loan, want to try share this unit along, and get myself a pickup coil and wireless that is easier to hack. (wired or wireless does not matter really.) My intention is to buy a Maplin unit which they sell for £40, and then hack either the wireless (433 MHz) or the internet API it has .
More info on the Efergy , harvested from the forums is this kind blog link detailing some of the protocols.

Wednesday, 10 May 2017

Storage closet 5c

passcode: 1721
5C notice board: orsyr ii
5C exit code: 2954