TIP: fix bizarre Docker problems

Docker, Testing
docker rm -fv $(docker ps -aq)Sometimes testing produces strange Docker-related problems.  The above command kills all containers, including the stopped ones.  The "-v" also destroys each container's private storage volumes.  This is great because Docker likes to run differently different times you run it -- because it has local state.  Local state is evil!  Run the above command every now and then so Docker starts from a clean, state-less, state.In Docker, stopping a container is different from killing it.  The former stops the running container/process, but leaves the private volume.  The latter zaps the volume.Thanks Sam!
Read More

talk: Platonic Solids of Quality

Appearance, Testing
(This page is bit.ly/jta-platonic )Slides: John Tells All: Platonic Solids of QualityVideo: Platonic Solids of Quality, John Tells AllDetailed outline on WorkflowyThanks to Don Westland for the A/V, Marcel for organizing and the picture, DataScience Inc for the hosting, and Keith B. for the presentation and the smooooth scotch.
Read More

Speeding up UI Browser tests with Robot Framework

Dev, Testing
My current AWS demo project is a Cat Voting Booth.  It uses SocketIO/WebSockets, so in addition to server-side unit tests I've built a number of browser-level tests, using Robot Framework.One feature people don't realize is that Robot can actually be quite speedy. Opening and closing a browser window is very slow, on the order of 1-2 seconds. Depending on the application, this can be done once, saving 1-2 seconds for *every* test!  For my Very Important Cat Voting Booth, this is the case. Here's the magic bit:*** Settings ***Resource          resource.robotTest Setup        Reset VotesSuite Setup       Open Browser To Voting PageSuite Teardown    Close All Browsers*** Test Cases ***Valid Page    Votes Not AvailableRegister Up Vote    Vote Up    Element Text…
Read More

pragmatic Test Driven Development

Testing
As a dev, I write mostly unit tests and care about test coverage increasing over time.  My view has shifted recently.Although web UI tests can be fragile, they present a lot of bang for the buck, coverage-wise.  It turns out they also have a lot of unique business value; that is, if we're testing what our users see, then when we change something we can immediately know that business value is being affected.- I recommend view-level tests. Django directly supports and advocates this style. They're fast and easy to create like Unit tests, but have direct user-level (thus business-level) value.- for UI tests, set an ID on everything that you are testing. (Never ever use XPath.)  This makes UI tests more durable and reliable. - Kent Beck has been the main…
Read More

Quality DevOps: installing and verifying Network Time Protocol (NTP)

DevOps, Testing
I lurve Ansible. It lets me install or update software on one or 100 instances, easily. The entire system becomes a set of scripts to run and run and run again until I get things exactly the way I want them.In today's devops ecosystem, where "infrastructure is code", how do we test our infrastructure?Ansible gives us one way to do this.  When we install or update a service, run a service-specific command to make doubly sure that things are working as expected. If something's not quite right, Ansible will abort and we can figure out what went kablooey.Save the following into "ntp.yml" and run with ansible-playbook -vvi myhost ntp.ymlThanks to phillipuniverse !# ntp.yml -- install NTP time sync daemon# Adapted from https://gist.github.com/phillipuniverse/7721288#file-ntp_playbook-yml## USAGE: ansible-playbook -vvi myhost ntp.yml#---- hosts: all  become: yes  gather_facts:…
Read More

Django trick: keep "runserver" from crashing on Python syntax error

Dev, DevOps, Testing
When developing Django, the "runserver" command is convenient. It runs our appserver, and reloads itself when we change our app's source code.  We can have a rapid "edit stuff then see what happened" cycle. However, runserver it has an annoying habit. If we're typing so fast that we add a Python syntax error into our code, the  command will crash. We expect that when we fix the syntax error, we can see our results, but it doesn't work. The appserver has crashed, and is no more.   The following workaround works wonders. If we add a syntax error, "runserver" will crash, and this loop will wait for a moment then re-run it. We can now type as fast as possible all the time, and Django will always show us what…
Read More

Django: speed up Sqlite 1000x!

Dev, Testing
I'm working on a project analyzing large code bases. For just messing around, I'm using Sqlite. A strange thing happened when updating ~10,000 rows: they were really slow! Sqlite was updating about 10 records a second.It turns out Sqlite correctly cares about your data, so it makes a transaction around the UPDATE statement, verifying that each and every bit of your data hits disk before returning. For me, if disaster strikes and I lose my tiny database I can recreated in a few seconds, so I decided to live life dangerously, and tell Sqlite to go ahead and try to update data, but don't wait around for it to hit disk.Here's the magic. Put this before your bulk INSERT/UPDATE statements. Note that it affects the entire session, so you don't…
Read More

speeding up tests with Postgres

Dev, DevOps, Testing
Dear Lazyweb,I'm developing a site using Django and Postgres. How can I get my tests to run a lot faster?Answer: tell Postgres to use a tablespace in RAM. Selects, updates, and inserts will run at fast RAM speed vs slow disk speed.Caveat: this doesn't work for writes. Postgres is designed to keep data reliable at all times. Any INSERT/UPDATE/DELETE gets written to a "write-ahead log" (WAL), so that if the database crashed it'll restore the data.  Since this is on a disk no matter what the tablespace, the above trick doesn't work without defeating the WAL.Answer2: use UNLOGGED tables, TBD.Reference:Unlogged table performance in postgresql 9.1: (2011) "unlogged tables have shown an increase of output by 13~17%"; includes performance-oriented Postgres settings.WAITING FOR 9.1 – UNLOGGED TABLES (2011): "that's really fast"wal_buffers performance…
Read More

link: Functional Programming in companies

Dev, Testing
There's a lot of interest and mystery about Functional Programming.  This is one of an ongoing series of posts about it.In the linked post, author Duncan McGreggor estimates only 10-20% of US tech companies have major investments in Functional Programming. Notable abstainer: Google. Why?New programmers with little experience to defend find it easier to learn new methodologies. Senior engineers will pick up new tech, like Functional Programming, if they're 1) research/academic oriented, 2) easily bored, or 3) have little competitive drive.  FP seems to be most adopted by smaller companies, because it's easier to hire/train up a critical mass of experts in the subject.I've typed "Functional Programming and other new technologies", although FP is as old as Lisp -- 1950s!  There are theories why Lisp didn't take over the world,…
Read More