AMA: Separate Repository for e2e Tests?

Liam asks…

“I did enjoy reading the article about e2e test on wordpress. I noted that e2e test are in a separate repo.

My question will be what is the workflow to make sure new changes does not break the e2e test on pull request ?

For example, if a developer work on some changes, then they need to change the e2e test first and make sure everything pass, however the environment on the pull request might not be stable, developer can overwrite each other changes”

My response…

Thanks for your question Liam.

We have reasons for and benefits in having the WordPress.com e2e tests in a separate repository:

  1. The e2e tests test the entire WordPress.com experience so these test things that happen in different repositories (for example our Calypso user interface or services/API) and having them in the user interface repository isn’t really representative of what the breadth of their scope;
  2. Making changes to the e2e tests are easier in a separate repository since we don’t have to deploy e2e PRs that don’t contain functional changes (we deploy every merge to our master branch immediately dozens of times per day)

The obvious downsides are:

  1. How do we make sure e2e tests know about incoming AB tests?
  2. How do we couple new changes to updates in the e2e test repository?

For incoming AB tests we make sure that our e2e tests know about the change by ensuring we create a matching PR in our e2e tests that override our AB tests during our test runs.

If someone updates the AB tests in Calypso they’re politely reminded to update the e2e tests:

Screen Shot 2018-09-19 at 3.31.47 pm
example prompt

For making sure e2e tests are up to date we automatically run two (of about 40 total) of the most critical e2e tests (in three browsers) when a PR is ready to be reviewed. These can fail and indicate a change is necessary to the e2e tests (or something is broken!)

There’s also a label we can add to any PR that runs the entire set of e2e tests against a PR running live and reports the result back to that PR:

Screen Shot 2018-09-19 at 3.38.29 pm
e2e Test Results against a Calypso PR

If changes are required to the e2e tests someone can create an e2e PR with the exact same branch name which will be used to run against the feature changes before they are merged. This means PRs can be coupled and tested together but merged separately.

To answer the second part of your question I understand it to be about conflicting changes? One of our key philosophies for work is “merge early and merge often” so we make sure that PRs are short-lived and merged quickly to minimize the chance of conflicts. These still do happen occasionally, we just deal with them as they come up.

Whilst there’s been some downsides to the separate repositories all-in-all the benefits continue to outweigh the downsides but we constantly assess and at any point in time we can easily merge them if need be.

Three Years of Working From Home

This month marks my three year anniversary (Matticversary) at Automattic, which  means I have been solely working from home for three years now.

Working from home every day can at times feel like either, or both, the best thing in the world, or the worse thing ever invented. I personally don’t believe that full-time working from home is suitable for everyone as I’ve found it orders of magnitude more difficult than working in an office environment.

i-cant-remember-do-i-work-at-home-or-do-i-live-david-sipress

It’s taken me almost three years to really work out what works well for me as a full time “telecommuter” – and I thought I’d use my work anniversary to share some of these.

Like anything, you’re mileage my vary, but these tips have definitely helped me over the years.

    1. Create a morning routine: since I don’t commute I’ve found it hard to mentally separate finishing non-work time and starting work time in the morning which is something a commute provides (without you realising). Since I have a flexible schedule I make sure that in the mornings I have a routine. I am lucky enough to live right next to a beautiful forest so I go for a 4-5km walk each morning which not only provides exercise and nature exposure benefits but symbolises to my brain that work  begins at the end of my morning walk. This can sometimes be hard to justify to myself as some of my colleagues are finishing up around the same time as I am walking – and I may miss checking in with them – but I definitely need this morning routine.
    2. Dedicate a home office space: as a family of five we live in a small cottage so it’s hard to justify a dedicated home office space in our home, but I’ve found it vital for separating my home and work lives. When I’m in the office I am working – when I am not in the office I am not working. My three children know they can’t play in my office – if I take a break to spend time with them I come out of my work space. I read in The Organized Mind book that “students who studied for an exam in the room they later took it in did better than students who studied somewhere else”. I believe this is due to the mental association.
    3. Dedicate a computer just to work: again this seems luxurious but having a dedicated work computer, or at least a dedicated computer profile/account, creates a good association between that computer and work. From The Organized Mind book again: “Create different desktop patterns on them so that the visual cues help to remind you, and put you in the proper place-memory context, of each computer’s domain“.
    4. Disable app notifications on your phone: unless I’m an in person work meetup (which happens a few times a year) I disable app notifications on my phone for work apps (like Slack, WordPress and GMail) which means I rarely check or open those apps outside of my work environment (see #2 and #3).
    5. Avoid checking work in bed: it’s very tempting to check on work things on my mobile phone in bed, particularly when you work for a global 24×7 365 company like I do, but this disrespects the importance of sleep in our lives. As Matthew Walker, one of the world’s leading sleep scientists says in Why We Sleep: “The silent sleep loss epidemic is the greatest public health challenge we face in the twenty-first century in developed nations. If we wish to avoid the suffocating noose of sleep neglect, the premature death it inflicts, and the sickening health it invites, a radical shift in our personal, cultural, professional and societal appreciation of sleep must occur.” You can use a morning ritual (see #1) to signify when you’ll start checking work things, instead of opening your eyes in bed and checking work immediately.
    6. Create an end of work day ritual: I am my most productive in the hours leading to dinner time so I use dinner time as my end of the work day ritual when I transition from working to not-working. I also have a couple of apps on my phone I like using and I don’t let myself use them during the day so I can signify at the end of the work day when I’m not working. Like a play reward that a working dog gets when they’re finishing working.
    7. Find social activities outside of work: working from home all the time can get very, very lonely and you can feel particularly isolated – especially working for a global company with flexible work hours, and having no team members close to your timezone. It’s important to find social activities outside of work as working in an office a lot of this is a given – even something like chatting to someone in the coffee room you won’t get working from home. I’ve tried attending Toastmasters, hiking groups and making sure I get along to meetups and user groups. Also I recommend meeting up with friends and ex-colleagues for lunches – travelling to where they work. This gives you a good break from working from home and can reduce the feeling of isolation.
    8. Spend some time away from home on holiday: this is one of the most expensive parts of working from home in my opinion, and it is easy to blow all the cost savings of not-commuting on holidays away from home that you need so you don’t feel like you’re at work. If you take time off and just stay at home (sometimes known as a “staycation”) I have found I don’t feel like I’ve really disconnected from work as I’m still thinking about work being home (even though I have a dedicated workplace – see #2). I’d love to work out a way to solve this one without spending more and more money on holidays away from home.
    9. Have something to listen to: I listen to electronic dance music mixes on Mixcloud all day long – but your tastes may vary. This provides a soundtrack for working.
    10. Set yourself a daily goal: I work in a Results Only Work Environment where my employer doesn’t care so much about my hours as long as I achieve results. This is both good and bad (I could write an entire post on it) but you need to be disciplined and set your set a daily goal and stick to it. Sometimes this means working longer than you planned, other times it’s important if you achieve your daily goal earlier than expected you finish earlier than expected to make up for all those other times. Otherwise you can get caught in a never-ending work loop.
    11. Close loops: working in a distributed work environment I find I have lots of different things on the go at any one time – this is because I might be expecting a reply or some work from someone else on something and everyone works different hours and lives in various time-zones. I find it’s important to re-visit all these “open loops” and close them, just so your mind doesn’t think about them anymore. This is sometimes a case of leaving a comment like “I didn’t hear anything back on it so I’ll close it” to close the loop – and remove it from your focus and bandwidth.
    12. Find tasks that you can finish to completion outside of work: most of the things I work on have a medium-to-long event horizon – or an indefinite horizon as I await asynchronous feedback – so I’ve found hobbies that I can finish completely in one attempt – gardening, cooking a meal, washing the car etc. are very important for my mental well-being as I get a good sense of accomplishment with these tasks and hobbies. See #11
    13. Getting things done creates motivation to do more things: when I lack motivation to start something I find the smallest thing that I can get done and complete that. The sense of accomplishment of getting something done motivates me to do more.
    14. Over-communicate: I can’t emphasise this enough – no one will see you in the corner of an office getting stuck on a problem – you need to constantly communicate everything you’re doing – good and bad. Communicating context creates empathy in a distributed team.
    15. Set expectations for family and friends: some people assume you’re not really “working” if you work from home. Setting aside a work space (#2) helps – but you’ll need to continually explain to people that even though you are at home you are actually at work.
    16. Don’t be afraid to ask ‘stupid’ questions: in a work from home environment there’s bound to be other people thinking the exact same thing as you – so ask away!
    17. Don’t be afraid to be a bit weird:Today you are you, that is truer than true. There is no one alive who is youer than you” (Dr Seuss)

 

That about covers it for now. As I said, working from home can be very rewarding, but it’s one of the hardest challenges I’ve ever faced, and after three years I’m still working at it!

Testbash Australia 2018

I only speak at one conference a year and this year that conference will be the first ever Australian Testbash in Sydney on October 19, 2018:

TestBash_Australia_2018_Adverts_DOJO_EVENT_BANNER.png

My talk:

At WordPress.com we constantly deliver changes to our millions of customers – in the past month alone we released our React web client 563 times; over 18 releases every day. We don’t conduct any manual regression testing, and we only employ 5 software testers in a company of ~680 people with ~230 developers across . So, how do we ensure our customers get a consistently great user experience with all this rapid change?

Our automated end-to-end (e2e) tests give us confidence to release small frequent changes constantly to all our different applications and platforms knowing that our customers can continue to use our products to achieve their desires.

Alister will share how these automated tests are written and work, some of the benefits and challenges we’ve seen in implementing these tests, and what we have planned for future iterations.

Takeaways: How to effectively use automated end-to-end testing to ensure a consistent user experience in high frequency delivery environments

Grab a ticket before they sell out #

→ How Canaries Help Us Merge Good Pull Requests

I recently published an article on the WordPress.com Developer’s Blog about how we run automated canary tests on pull requests to give us confidence to release frequent changes without breaking things. Feel free to check it out.

AMA: BA roles in Automattic?

Iroy asks…

Automattic uses interesting and fun names for different roles (QA being excellence wrangler). Are there Business Analyst roles in Automattic? If so, what is it called?

My Response…

At Automattic we differentiate between a Job Title and a Role. My (current) job title is indeed Excellence Wrangler and my role is Code Wrangling. Anyone is free to change their job title to anything they like at any time so we have some fun ones, whereas the roles are pretty static.

Continue reading “AMA: BA roles in Automattic?”

Finding a home for your content

I’ve been blogging on WordPress.com for over nine years and I’m very happy with my decision to become both a WordPress.com user back then, and a WordPress.com (Automattic) employee in 2015.

Continue reading “Finding a home for your content”

Feature Toggles for Automated e2e Tests

Feature toggles aren’t just for production code. Feature toggles are also a powerful technique to change the behaviour of your automated end-to-end tests without changing code.

Continue reading “Feature Toggles for Automated e2e Tests”

The Importance of Doing Customer Support

One of the many, many things I love about working at Automattic is the being part of a company that sees huge value in everyone spending time doing customer support, and acts on it:

“When you join full-time, you’ll do customer support for WordPress.com for your first three weeks and spend a week in support annually, for evermore, regardless of your position. We believe an early and ongoing connection with the people who use our products is irreplaceable.”

Automattic’s Work With Us Page

Every single bit of that statement is true: I did three full weeks when I joined last September, and I’ve already done an additional week this year.

Continue reading “The Importance of Doing Customer Support”

AMA: running e2e tests continually

Clark Hamilton asks…

What do you think about running e2e GUI tests continually and displaying the results on a real-time dashboard? We could build such a system but maybe there is an open-source solution we don’t know about. We’re using Mocha with webdriverio and found your articles useful. Appreciate your thoughts!

My response…

We currently do something like this for WordPress.com. We have our e2e tests (now open source) which are run in three different circumstances:

  1. on every deploy to WordPress.com (tens of times per day); and
  2. every 6 hours from UTC 0:00 (to pick up issues like connectivity that happen independent of deployments); and
  3. every time a change to the e2e tests is merged into the master branch.

We do this using CircleCI which connects to Github to perform #3 automatically. With #1 and #2 we use the CircelCI API to trigger builds on the master branch during our deploy process and every 6 hours using a cron job.

As for a dashboard, we use the CircleCI results page which shows the history of each run, and we also have some slack channels set up which also get real time notifications of results, and any tests that fail (including screenshots). The way we do this is in our source code.

Since we’re a 100% distributed company with no offices we don’t have any build lights/monitors etc. for an office space, we just individually use our own channels to monitor these test results.

WordPress.com e2e Automated Tests Now Open Source

I am very pleased to announce that all of our e2e tests for the WordPress.com platform are open source as of this morning. This is following in the footsteps of the WordPress.com Calypso front-end which is also open source.

I am continually reminded of how fortunate I am to work at Automattic who takes pride in its commitment to Default to Open:

“The quality of our code and our product depend on the amount of feedback we get and on the amount of people who use them. If we’re developing behind closed doors, we are putting artificial limits to both.

We have done our best work in the open, let’s continue working this way.”

~ Matt Mullenweg, CEO Automattic

Our ongoing development of these tests is in the open. So please feel free to take a look through our e2e tests, their CI results, and fork them, provide us some feedback, or use some of our ideas. And pull requests are always welcome 😀

Running Automated Tests with A/B Testing

Like a lot of modern, data driven sites, WordPress.com uses A/B testing extensively to introduce new features. These tests may be as simple as a label change or as complex as changing the entire sign up flow, for example by offering a free trial.

Since I have been working on a set of automated end-to-end tests for WordPress.com, I have found A/B testing to be problematic for automated testing on this very fast moving codebase, namely:

  1. Automated tests need to be deterministic: having a randomised experiment as an A/B test means the first test run may get an entirely different sign up flow than a second test run which is very hard to automate; and
  2. Automated tests need to know which experiments are running otherwise they may encounter unexpected behaviour randomly.

What we need is two methods to deal with A/B tests when running automated tests:

  1. We need to be able to see which A/B tests are active and compare this to a known list of expected A/B tests – so that we don’t suddenly encounter some unexpected/random behaviour for some of our test runs
  2. We need to be able to set the desired behaviour to the control group so that are our tests are deterministic.

Different sites conduct A/B testing using different tools and approaches, WordPress.com uses HTML5 local storage to set which A/B tests are active and which group the user belongs to.

Luckily it’s easy to read and update local storage using WebDriver and JavaScript. This means our approach is to:

  1. Each time a page object is initialised, there is a call on the base page model that checks the A/B tests that are active using something like return window.localStorage.ABTests; and then compares this to the known list of A/B tests which are checked in as a config item. This fails the test if there’s a new A/B test introduced that isn’t in the list of known tests. This is better than not knowing about the A/B test and failing based upon some non-deterministic behaviour.
  2. When a new A/B test is introduced and we wish to ensure our automated tests always use the control group, we can set this using a similar method window.localStorage.setItem('ABTests','{"flow":"default"}'); and refresh the page.

Ideally it would be good to know and plan every A/B test for our automated e2e tests, but since this isn’t possible, checking against known A/B tests and ensuring control groups are set means our automated tests are at least more consistent and deterministic, and fail a lot faster and more consistently when a new A/B test has been introduced.

How do you deal with non-determinism with A/B tests?

Comparison of JavaScript browser automation and test specification libraries

As part of my trial for my current role at Automattic, I was tasked with implementing some e2e acceptance tests using my choice of library/framework/language.

I very much recommend writing automated acceptance tests in the same language as your app, even though I have described some benefits of using a different language, and since WordPress is moving towards JavaScript from PHP, JavaScript seems the most suitable language for Automattic.

Continue reading “Comparison of JavaScript browser automation and test specification libraries”

Bush Walking (or how a wasp can destroy your iPhone)

Everyone at the Automattic Grand Meetup is required to give a 4 minute (or less) flash talk about any topic they like. I told a story about how I was stung by a wasp bush walking. This was my talk:

Bush Walking by Alister Scott (16)

Continue reading “Bush Walking (or how a wasp can destroy your iPhone)”

Automattic Grand Meetup

My first few weeks working at Automattic (WordPress.com) have been great. As I mentioned previously; I spent my first three weeks on customer support (like everyone else), and this week I am in Park City, Utah for our annual all company meetup (Automattic Grand Meetup).

Since Automattic is a 100% distributed company with about 400 staff across 36 countries, it’s important to have face-to-face contact a few times a year, and this is the biggest meetup where everyone from across the globe comes together. Other meetups throughout the year are for teams or projects and are much smaller.

Park City is a very pretty place, I’ve enjoyed my time here. Here’s some of my photos.