Automated Exploratory Test Fixtures

This is part 3 in my series about  BDD and MicroServices. You may want to read part 1, and part 2 first.  

As I have blogged about earlier, I have been spending some time exploring BDD/executable examples in a MicroServices environment, and how we can benefit from executable examples (SBE, Specification By Example) here at SpeedLedger. It has been a really good learning experience, and fun too.
Thanks to the initial progress, I have managed to persuade my boss to let me work on this full time! We are doing it as an time-limited experiment, but hopefully this will be extended.

In this blog post, I would like to share one of our greatest takeaway so far: That End-to-End Exploratory Testing is more valuable than End-to-End Regression Testing.
Both categories are valuable of course, but if I had to choose to have a really good setup for exploratory tests OR only a great suite of regression tests, I would definitely choose the former. Having automated fixtures (setup procedures) for interesting “moments” in the lives of our customers when using our product is super valuable, and I will list the reasons below.

 

When all this started, we named the experiment “BDD across team borders”. This was a good name at the time, but we later realised that the benefits of BDD/SBE can be appreciated by all co-workers, even those outside development teams. We have identified three main areas where we – as a company – can benefit from automated environments and automated test data:

Learn

If you are teaching yourself a new app/system/service, wouldn’t it be great if you could experiment and explore all aspects of it without being afraid to destroy anything? And in a simple way set up situations that the typical customers face every day?
Similarly, if you are training a new hire about your system; Wouldn’t the training be more efficient and fun if you could go through these scenarios interactively, setting them up with the touch of a button?

Discuss

When discussing existing or new features with you peers, what would it be like if you could throw up a the system on a wide-screen monitor, demoing the current feature in question and the proposed solution respectively. While being able to repeat all setup step automatically and indefinitely?
Compare this to discussing features with the help of only stale sketches or obscure user stories.

Verify

This is the obvious one, of course. Most people think that verification of current features is the only benefit of automated test. But as we have seen above, there are several nice bonus effects.
In addition, there are other – maybe more subtle – positive side effects that come from using the test-first mindset. But that is a different story…

How about you? Can you automatically setup the preconditions for your customers’ most interesting interactions with your product?

 

 

 

Speaking at FlatMap Oslo about Property Based Testing

In the beginning of May I’m heading to FlatMap in Oslo to give a 90 minute workshop about Better testing with less code.  I will go through the basics of property based testing with ScalaCheck. About half the time will be hands on exercises to get a feel for the framework a get comfortable enough to start using it in your own projects. The exercises and presentation can be found in my github repo.

I find it very rewarding to speak at conferences and agree with everyone that says that the best way to get a deeper understanding of a subject is to start teaching it to others.

Outside-in — To the max! (BDD and Microservices part 2)

This is part 2 in a series about my 20% project BDD across team bordersPart 1 can be found here.  

When writing any piece of software, it’s very easy to start working on the details before you have enough knowledge about the targeted context. I think most developers recognize this pattern:
You start with some innocent (often unintentional) guessing about one or a few unknowns. Pretty soon the guesses turn into assumptions and before you know it they have morphed into ‘truths’. You happily code away with these truths as your guiding light. Later, when you try to integrate your code into a bigger context, the assumptions and truths fall apart and you need to rethink your work.

– Oh, is that how the incoming data looks like!
– Why didn’t anybody tell me I have to ask the database for that value?


Personally, I have made these kinds of mistakes countless of times, and I will probably make many similar ones in the future. I think this is due to human nature; We really like making assumptions for some reason. To minimize the impact of this phenomenon, we have to try really hard to be aware of it at all times. We also have to find strategies and techniques that help us avoid making these false assumptions.

spiralTest Driven Development (TDD) is one excellent tool for this purpose. It forces us to step outside of the current context and look at the problem from the outside, or from “one level above” if you wish. More importantly, the TDD approach fits on all levels of software development! No matter if your context is a oneliner method in a class or the public API of a complete service, you always benefit from taking one symbolic step out of your current context.

In my 20% project BDD across team borders, I wanted to take this line of thinking to the extreme, and work on the highest level possible, thus making sure I was taking the “outside-in” approach to the max, maximizing our helicopter view in the process.
I set as a constraint on my work going forward that I was only allowed to write the BDD tests against our publicly available APIs and web pages. No matter how tempting, I would not “cheat” by calling internal APIs or access anything not available to a user in production. If I did, I would risk getting my assumptions wrong, as described above.

Working against public APIs also provides another great bonus;  It forces you to write user-centric stories that are sliced vertically. A good rule is that “Every story must have a noticable effect on the public API level”. If you write a story that has no noticable effect for any user, you have not succeeded in writing a vertical story.

My claim to test on the “highest possible level” is not entirely true, of course. There will always be third party dependencies and other integration points that we cannot incorporate in the system under test. We will have to fake or mock things like partner APIs, for instance. As long as we don’t mock or fake our own code or apps, we should be good to go!

I want my helicopter view back! (BDD and Microservices, part 1)

502377266

Here at SpeedLedger Engineering, we took the plunge into the world of microservices some time ago. We have gradually phased out our old monolithic style applications in favor of many small and independent micro services/apps.

Overall, the micro services paradigm aligns very well with our organization (small independent teams) and we are getting pretty good at it, I must say! We are constantly improving our infrastructure and deployment tools, enabling us to develop and deploy quicker and more often. As a result, the general time-to-market has decreased and our customers are getting more new features, sooner.

However, one big drawback of working in isolated islands of people and code is that you risk losing the big picture, the “helicopter view”. Unsurprisingly, this is what happened to me and my teammates. We often found ourselves asking questions like:

  • What’s supposed to happen in this business flow?
  • What are the possible inputs to this API?
  • Which apps will call this endpoint?

The answers to these and similar questions are not impossible to find but it always takes valuable time to track them down and to get them clarified.  

I felt something had to be done about this situation. For a long time, I have been a fan of BDD (Behavior Driven Development) but I never really got my feet wet in a real world situation. I suspected our current situation could benefit a lot from a successful BDD effort, and that it provided a perfect opportunity for me to experiment with and learn more about BDD.

For someone who doesn’t know what BDD  is, it can be described as “executable documentation” or “executable examples” that a non-programmer can understand and edit. More about this later…

After some initial discussion, we decided that I would do this in the context of a “personal 20 percent project”, famously invented and used by Google.  The main reason being that part of the work had to be done outside the team boundary, touching all the other teams in some way. In line with this, we actually named the project “BDD across team borders”. 

This was in February, and since then I have spent most of my Fridays exploring the possibilities of introducing BDD at SpeedLedger, and – more generally – automated testing on the highest possible level in a microservices environment.  In a series of coming posts, I will blog about BDD and the progress of the project. Hopefully someone will find it interesting. Also, I would love to get some feedback from you blog readers along the way!

 

QCon London venue

QCon London 2016

 

I’ll try to summarize three great days at QCon in London, not going into detail about all sessions that I attended but high-lighting some of the ones I really liked.
Most sessions were recorded and will be available for the public audience over time, make sure to check them out!

 

QCon offers a wide variety of tracks ranging from low level “Close to the metal” to more “soft” skills like “Optimizing You”.  There were also a track for the main sponsors of the conference. The wide variety of content and speakers made choosing what session to attend somewhat of a problem; I had made a schedule before traveling to the conference, and it broke down during the first presentation of the tracks before the first keynote…
Kicking of QCon was a great keynote “Unevenly Distributed” by Adrian Colyer. Adrian reads a paper a day, summarises it and publishes it on his blog “The Morning Paper”. This was a very inspiring and well presented keynote that raised my interest in reading papers and as Adrian said “5 reasons to love papers”:

  • Great thinking tools
  • Raise your expectations
  • Applied lessons
  •  Great conversation
  • Unevenly distributed

The only problem with reading more papers and learning more is that:

“The more I learn, the more I realize how much I don’t know.” – Einstein

After the keynote we listened to Gavin Stevenson, Engineering Lead at WilliamHill, who talked about WilliamHills betting engine and how they are transitioning from a large database centric solution to a micro service based architecture (this was a common theme during the conference). They were building a “production ready” betting engine in 2 week sprints, testing it with real production data. The most interesting take away was how important it is to really try to break your system. When the system fails, that’s when you learn. The old saying “If it ain’t broken, don’t fix it” just doesn’t apply anymore.

“If it ain’t broken, try harder!” – Gavin on testing

One of the few really non-software related talks was held by long distance runner Simon Wheatcroft.
When losing his sight the age of 17 due to a genetic degenerative eye condition, he began a journey of adapting tech to achive the impossible.
Through the aid of the Runkeeper application, he started running solo outdoors. Simon will be running his first solo race in May 2016; the Four Deserts Series Sahara Race in Namibia. There, he’ll use GPS coordinates and a mobile app to navigate across the 250 kilometer distance.
A very inspirational and humbling talk!

“You just have to tell yourself that pain doesn’t last forever”- Simon on running 250k

From non-technical to real in-depth low level Netty implementation details. Norman Maurer from Apple described how Apple is using Netty as a web service delivery platform for most of Apple services. Apple are running 550000+ Netty based services, handling 10s of Petabytes of data every day and millions of request per second.
Norman guided us in different aspects of the Netty framework and how the default JDK implemtations just aren’t good enough for this kind of load and how they’ve commited several improvements to the Netty open source code. Very interesting and down to the metal of how to hack the JDK and using JNI to get better performance with; for example memory allocation and SSL.

Martin Kleppmann held one of the best presentations of the whole conference where he talked about keeping data sources in sync, moving away from (distributed) transactions to streams. The content was not very in-depth, but Martin had deep knowledge of the subject, excellent slide and a lot of energy when presenting. This is a talk everyone should watch and learn from.

“Stupidly simple solutions are the best” – Martin Kleppman

Day two started with Linda Northrops keynote “Reflections on Software Architecture”. Linda looked at software architecture and how it’s importance and acceptance have changed over the last 20 years. To summarize: architecture is important, and it’s a way to manage technical debt.

Josh Evans from Netflix presented how Netflix have expanded there streaming services to almost the entire globe (Netflix#Everywhere).
Netflix have had some major outages and failures, both in their own software and the underlying cloud AWS-platform. Josh concludes that “Failure is inevitable” and that one really have to embrace the failure and not fail in the same way twice. This had lead Netflix to embrace a “Failure-driven architecture” approach when building their platform.
Netflix’s architecture is really impressive, although not applicable for most comapanies/services, so it’s always interesting to hear what they are doing to actually run the platform at that scale.
Josh presented Netflix four architecture pillars; data, caching, traffic and micro services, and how they use (among other techs) EVCache, Cassandra and DNS to keep their services up and running in case of total failures of an AWS datacenter/region. He also showed how they test failure in different regions and route trafic to another region to minimize customer impact.
If infrastructure and architecture at scale is of any interest, watch this talk when it comes online!

“Never fail in the same way twice” – Josh Evans

Mitchell Hashimoto (founder of Hashicorp) gave his talk “Observe, Enhance, Control: From VMs to Containers”. In his talk he takes us back to 2006 and the age of VMs and how the datacenters and the problems to solve are driving the architecture of the software for Monitoring, Configuration and Deployment. Jumping to 2016 and the age of containers, Mitchell argues that the “state-of-the-art” tools from the age of VMs are not really suited to handle the tasks anymore. Even though the tools are extremely good, they do solve a completely different problem. The content of the talk was nothing new, but it is really inspiring to listen to Mitchell talk.

Gil Tene talked about Hardware Transactional Memory. Really low-level stuff about CPU pipeline and cache optimization. HTM in the JVM is not new, Azul has been delivering both hardware and a customized JVM with JVM for 10 years. What’s interesting is that it will become mainstream now when Intel is shipping CPUs with support for HTM. Gil succeeded in a very educational way describe the complexity of HTM and how it can be implemented in for example the standard JVM. In the end Gil talked about how the developers must reason about locking and synchronization to make the most of HTM in their code.

One of my most anticipated talks during the week was Dan North‘s “Making a sandwich”. I hade very high expectations for this talk, and Dan managed to exceeded them (as usual). Dan talked about giving feedback, how feedback in itself is a system and why we should do it. Giving and receiving feedback (which is really just to say ‘Thank you’) is, in my opinion, one of the hardest skills to master and we should really practice a lot! Dan presented some useful techniques and tricks, but you should really watch this yourself!

Last day started with a very entertaining and inspiring keynote delivered by Kolton Andrus (Netflix) and Peter Alvaro (University of California). Peter and Kolton shared their expereience of a very successful collaboration between industry and academia. Peter had a “big idea”, Lineage-driven fault injection, and together with Kolton this evolved from a theoretical model into an automated failure testing system that leverages Netflix’s state-of-the-art fault injection and tracing infrastructures.

“My code is now actually running live on Netflix…” “…well, minus all of the println statements”

Vikki Read and Alex Wilson from Unruly described how they are using the extreme programming (XP) ideas to deliver high quality software and how it can be made to work in a very agile environment. Since agile and XP focus a lot on collaboration and knowledge sharing, they shared some problems that they’ve had with getting new employees up to speed and how growing teams make for example (too long) stand-ups being a problem.

The final session I attended before heading to the airport was Tammer Saleh at Pivotal talking about the mistakes people make when building a microservices architecture, i.e. Microservice anti-patterns. When are microservices appropriate as an alternative to the monolithic app? The problem with monolithic apps is not about the code, it’s about the teams! Large teams (or multiple teams) can’t work effectively in the same codebase.

Its not about code, its about teams

Its not about code, its about teams

Tammer stressed that “the most common mistake is to start with microservices”. Start monolithic and extract as needed, because microservices are complex and impose a constant tax to your development.
Tammer explores how to draw the lines between services. dealing with performance issues, testing and debugging techniques, managing a polyglot landscape and the explosion of platforms, managing failure and graceful degradation.

“Boring is beautiful” – Tammer Saleh

Most of the interesting sessions I attended during the week were about failure, and how to handle failures. Quotes like “Failure is inevitable”, “Failure is an opportunity to learn” and the importance of building an architecture that can manage failures were common topics. Migrating from a monolithic application to a more micro service oriented architecture were also popular.
Overall QCon London was a great conference, I will most likely try to get back next year! All tracks had great speakers, which is problematic since you have to choose between sessions – on the other hand most of the sessions are recorded so I know what I will be doing the coming weeks.

 

Do we need the database at all? – Event Sourcing!

WordPress › Error

There has been a critical error on this website.

Learn more about troubleshooting WordPress.