Wednesday, 6 October 2021

New Country, new domain name, new blog

Now that I have moved back to New Zealand, it makes sense for me to switch over to having a "dot en zed" domain name - like I have the "dot london" domain for this blog.

Domain name management has changed a bit since I left, so instead of having to decide whether I'm a ".co.nz" or ".org.nz" or something similar, I can just go for a top level ".nz".  My name of choice this time around is "sounie.nz".

The new blog can be found at blog.sounie.nz and is likely to become the main platform for my updates from now forward. If you get tired of seeing fresh posts there, don't worry I will most likely ease off once I start into a new job.


(PS: technically it's old country for me, but that didn't feel snappy enough to go in the title).

Saturday, 11 September 2021

How to test Spring's Transactional behaviour

Introduction

In order to properly test the behaviour of the software that we develop using frameworks such as Spring,  we need to run our code with the framework code and configuration in place.

A recent situation that I wanted to verify as working correctly involved a data access component which relied on Spring to rollback the underlying database transaction if an exception had occurred.

Level 1 - Unit testing

We could unit test the class by creating an instance of it and passing in mock collaborators to trigger exceptions, but that would silently ignore the @Transactional annotation, since the annotation is effectively just metadata for the relevant Spring logic to detect and wrap logic around.

@Test

void throwException() {

   Foo foo = new Foo("xyz", "Unit test example foo.");

   FooDAO fooDAO = new FooDAO(someMockConnection);

   try {

     fooDAO.updateFoo(foo);

     fail("Excepted exception to have been thrown");

  } catch (MyAppDataAccessException exception) {

    assertThat(exception.getMessage()).isEqualTo("Foo with id 'xyz' does not exist to be updated.");

  }

}

Level 2 - Component testing

Slice testing

- Have the test include part of the framework to create the component so that the framework will introduce the appropriate logic (extending or wrapping the object with a proxy for transaction handling).

Level 3 - Testing component within the app

To ensure that the layers all fit together in the way that we expect them to we can run the full application, using locally provisioned resources - e.g. with TestContainers providing a real database server.

There are some situations that can only be reached if another user or system happens to be interacting with the same data that we are operating on.  In my case the data was read in as part of validation prior to attempting to apply the database updates, so if the database representation didn't match at the start of processing then validation would fail and no update call would be made.

As an initial approach I have introduced a component into the test codebase which will be included as part of the running application.  It implements the validation interface with a behaviour combination of delaying processing before calling through to a delegate - in this case the real validation component.


Friday, 3 September 2021

The move back to New Zealand

The new flat

By August 2021 I was in a different flat and working from home on a fulltime basis.  There were some good and bad aspects of the new place:

Good:

 - Very limited shared living areas, so minimal risk of catching Covid if one of the new housemates got it

 - My bedroom overlooked a quiet(ish) garden area, and the flat was on a quieter side street

Bad:

 - Maintenance works that I was home for, including installation of a new boiler and clearing of existing radiators

 - Being home for deliveries - including a fridge freezer that the delivery guys weren't keen to lug up the narrow staircase

 - Long running complaints about noise from downstairs neighbours carried the potential for having to be significantly disrupted by installation of under floor soundproofing

Another lockdown

After a couple of months of being able to go out and meet with a very limited number of people "support bubble" to keep me sane, another UK lockdown followed including the cancellation of my very limited plans for Christmas.

Several months later the UK lockdown restrictions eased again.  Around this time I started to evaluate timelines and notice periods and the scarcity of places in New Zealand's Managed Isolation and Quarantine (MIQ) system.

Timing and luck

Because I needed to give 12 weeks notice for resigning from my job I would only look at the furthest future available dates in MIQ, as those timelines typically only showed the next three months or so of availability.

Sometime in May my employer's bonus announcement came through, so I set myself a timeline of resigning shortly after the bonus payment had made it into my bank account.  Around this time I was also fortunate to find that MIQ spaces for August had opened up, so I managed to reserve my MIQ stay from the last day of August and promptly booked a one way flight from London to Christchurch.

After serving out the notice period at my job I ended up with four weeks or so to finish organising my move - packing boxes and offloading things.

Avoiding Covid

I had hoped to enjoy some long walks around London on my own for the last couple of weeks - keeping isolated to reduce the risk of catching Covid, but then my knee decided that it had other ideas that involved leaving me unable to walk due to a minor injury that I had picked up almost exactly a year earlier.  I didn't want to risk picking up Covid from a visit to a doctor of MRI scanning place, so I spent a lot of time lying down and bought myself some crutches for the limited excursions out of the flat.

My first ever Covid test was the one that I had too book in for shortly prior to my flight home.  I was bricking it!  If that result came through as carryign the illness then I would have a few problems:

 - Nowhere to live, and no clarity around where in London would accept someone who is known to be carrying Covid-19

 - No source of income

 - No timeline for when I might next be able to attempt to travel to New Zealand (MIQ spaces were then an extremely sought after and scarce resource)

The flight home

The PCR test came back as negative for Covid-19, so the final requirement for being allowed onto the flight was in place.

On the first leg of the two hop journey I had a row of seats to myself, on the second flight I had almost an entire section of the aircraft to myself.  I'm curious whether the government may be subsidising the airlines to maintain the service, or if they are carrying more unaccompanied baggage than usual to make up for the lack of passengers.

Getting to MIQ

I used to live in Christchurch, so I had some ideas around the locations of hotels.  When the bus driver said it would be about a 20 minute ride to the MIQ facility I was relieved to realise that I wouldn't be stuck out in one of the hotels close to the airport.  I checked over the list of other possibilities and recalled that my old friends in the hospitality industry used to say nice things about Chateau on The Park...   I can confirm that it is a nice spot - I'm feeling comfortable, as I write this with my balcony doors open overlooking the exercise area in the Spring sunshine.

On the first night I couldn't sleep properly, so I went online to check the availability of online grocery orders.  The following afternoon I had a bunch of paper bags outside my door, filled with the goodies that I had ordered.

Tuesday, 29 December 2020

Less is More

This post shares a title with a little article that a university classmate authored a couple of decades ago - back before blogging was a thing, so the platform that hosted it no longer exists - so you’ll just have to take my word for that.

The article was a comparison of two commonly used unix shell commands that are commonly used for viewing the content of a text file one page or buffer at a time.  The gist was that the “less” command offered greater functionality than the “more” command.

Evidently the same phrase also has a more widely known history for architecture and design being more impactful when there is less complexity or clutter.

People use social media for different purposes, and with different expectations of how to interact. One such example that I was not directly involved in, but found to be particularly strange, was when someone who holds himself up as a community leader became abusive because somebody had commented on their completely public post on Twitter, responding that it was as if he had been interrupted by a stranger while talking with his mates in a pub.

So, I should have known better than to chime in with “Less is more” on another individual’s tweet after having listened to a podcast that had included them as a guest.

Makes me wonder whether anybody that I have blocked on Twitter has taken it personally.  I very much doubt it.

Tuesday, 22 September 2020

The Return to London After Spending Lockdown in New Zealand

Whenever possible I try to minimize the amount of unnecessary stress in my life.  Sometimes that involves flying to the other side of the planet during a global pandemic.

This can be considered as part two of my "What I did during the Coronavirus Pandemic" post - a series motivated by the old "What I did during the school holidays" essay theme from childhood.

In mid-July I made the decision to book my flights back to London.  By this point the infection rate in the UK looked like it was going down, and my old accommodation was less at risk, but a key motivator for moving back was to ensure that my tax situation would not become complicated due to the country of residence situation.

When I went online to book my travel I was thinking about the risk of catching the virus en route, so I aimed to minimise my travel time and transit stops.  I wanted to catch up with friends in Christchurch, so had that as my departure point.  Australia - particularly Melbourne - was experience an increase in cases of the virus, so I decided to avoid any transit stop there.  Hong Kong was still not looking great due to political unrest, so I ruled out having any stop there.  Singapore looked like a safe option, and had been okay when I had travelled from London to Christchurch a few months earlier.

A few weeks later I came to realise that I had made a slight boo-boo when booking my flights.  Although New Zealand was on the UK's list of countries that it was okay to travel from without having to go into self-isolation when arriving back, Singapore was not on the list.  By including a transit stop in Singapore airport in my return flights to get me back to London I had destined myself to 14 days of being stuck in the flat.

Part of my pre-flight entertainment in Christchurch was to try out setting up a delivery of groceries to my UK address so that I would have enough sustenance during my second round of self-isolation.  As the supply / demand balance of online grocery orders had gone into a sensible level, I was able to schedule a delivery for a few hours after my return.

Even with the benefit of hindsight I don't regret my decision to travel via Singapore.  Realistically, given the limited range of countries within the UK's "travel corridor", if I had set up a travel route only involving those countries I believe that I would have been more at risk of becoming infected.

Wednesday, 9 September 2020

What I did during the Coronavirus Pandemic

The move to New Zealand

On March 23rd I decided that there was too much uncertainty around how long London would be in lockdown, so I booked myself a flight to New Zealand to stay with family.

A few days later I was in Balclutha in time to hear the town's civil defence siren sound half an hour before the start of New Zealand's level four lockdown.

Due to the remote possibility of being a carrier of the virus, I had to self-isolate for two weeks from the day that I arrived.  This meant that I could not go to the supermarket (the only retail business still open).  I was still permitted to go outside and walk around, keeping my distance from anyone else who happened to be out and about at the same time.

Work

At the time that I left London my team had already started to work remotely, so I was able to continue to contribute to the software development effort from my laptop - just in a different timezone.

Online only job interviews

Participating in the job interview process is strange enough when meeting face to face in a meeting room in the office, but we had to adapt to try to achieve the same level of confidence with a candidate being met exclusively online.  The challenge that we didn't really solve was finding a suitable mechanism for having the applicant draw an architecture diagram for a hypothetical new system.

Staying connected

For my circle of friends back in London I found myself making new connections on Facebook with people who I would semi-regularly meet up with in the local pub.

My pub quiz team WhatsApp group also kept me informed of changes in my London neighbourhood, though I eventually found myself sending them pics and videos that I had received - such as how a local pub was temporarily converting itself into a delicatessen.

Post lockdown socialising

By the 21st of May New Zealand had gradually moved to a lower level of Covid-19 restrictions.  More shops could open, and cafés, restaurants and bars could operate with social distancing restrictions for customers, known as the three S's: seated, separated, and with a single server.

I didn't expect many businesses would open under the restrictions, as their overheads could be higher than before and the likely turnover could be expected to be much lower.

On one of my daily walks I came to realise that the pub closest to my side of the town was opening, so I decided to try it out for some food, beverages, and people watching - I hadn't really spoken to anyone beyond my immediate family for well over a month by that stage.