Automated Black-Box Tests for System Settings of a Micro-service Application

Automated Black-Box Tests for System Settings of a Micro-service Application

oCIS is the new generation open source file-sync and sharing platform, built by ownCloud , who also created the ownCloud 10 server based on the LAMP stack. The team of JankariTech is part of that development and mainly writes and maintains the automated tests.

The Challenge ??

Because a lot of APIs of oCIS still have to be compatible with ownCloud 10, we have used the existing API tests and (after some adjustments) ran them on oCIS to ensure the backward compatibility. I have written about that process in BDD on Software Rewrite.

This worked well for a lot of test cases, and we could quickly reach good coverage. But there were some cases where the old tests could not be reused. One of those cases is specific system-wide settings. In ownCloud 10 those settings are often set by the UI, an API call, or the designated CLI tool. Also, the changes can be done during runtime and are immediately effective. This is great for an API test: change the setting => check the expected behaviour! Easy!

Because of the different architecture of oCIS, system-wide settings are set through YML files or environment variables. This is great if you run the service in a container environment, but it makes automated testing harder. Logically, the settings are only read once during the start of the service and for any change to take effect, the service needs to be restarted. How to do that as an external black-box API test?

Not to test those settings or to rely only on manual tests was never an option.

First Iteration ??

We first started by creating different pipelines in CI that start oCIS with defined settings and ran specific tests against that instance. That gave quick results but soon became confusing because every combination of settings needs its own CI pipeline and a designated set of tests. Additionally, that system makes it hard for developers to run the tests in their environments.

Second Iteration ??

The next iteration was to write a small wrapper for the server?(of course,?it's written in Go,?the same as oCIS).

No alt text provided for this image

This wrapper starts the oCIS server,?monitors its state, and provides its own API that accepts lists of settings.?Whenever a test wants to change a system-wide setting of oCIS it sends the wrapper the desired environment variables.?The wrapper then exposes those to oCIS,?restarts oCIS and reports back the success of the reconfiguration.?The test can then go on and contact oCIS through its APIs and check if the new behavior is as expected.

No alt text provided for this image

To decouple test-cases from each other,?the wrapper also provides a special endpoint to completely reset oCIS to its default state.

All the kudos for this work goes to?Sajan Gurung!

Future Challenges ??

As we move forward with extending the test-coverage to new APIs and various different use-cases of oCIS we face further challenges. For example, oCIS can be connected with different storage providers (POSIX filesystem, EOS, S3, ownCloud 10). We are currently exploring what would be the best way and layer to test the functionality of the storage drivers. Unit tests, Contract tests, E2E API tests, something else?

I will keep posting about interesting developments in this test automation area.

要查看或添加评论,请登录

Artur Neumann的更多文章

  • Behaviour Driven Development on Software Rewrite

    Behaviour Driven Development on Software Rewrite

    Imagine you have an application, it works great, but you need to rewrite it, maybe because the architecture is hitting…

  • Contributing to up-stream projects

    Contributing to up-stream projects

    Behat is a BDD framework for PHP and it has a Cucumber parser called Gherkin. It’s a great tool but it missed a feature…

    1 条评论
  • Are you safe enough to take risks?

    Are you safe enough to take risks?

    Company values are great, but if they are only saved away in a document they are useless. The values need to be saved…

  • Demonstrating TDD (Test-driven development) in Go

    Demonstrating TDD (Test-driven development) in Go

    TDD is the practice to write tests before code and it should reduce failure rates and defects in your software. In this…

  • Demonstrating BDD (Behavior-driven development) in Go

    Demonstrating BDD (Behavior-driven development) in Go

    In "Demonstrating TDD (Test-driven development) in Go" I've written about TDD and this time I want to demonstrate BDD…

    1 条评论
  • Organize your company the geek-way

    Organize your company the geek-way

    How do you organize your documents in your department / company / startup ? Your policies, your minutes of meetings…

    2 条评论
  • Should you write acceptance tests for bugs?

    Should you write acceptance tests for bugs?

    As a developer or as a QA-engineer you found a bug in a piece of code, and you cannot fix it straight away (maybe its…

  • Git bisect – squash your regression bugs quicker

    Git bisect – squash your regression bugs quicker

    Git & Git bisect If you are a software developer or studying computer science or another IT subject, you probably have…

  • first 24h programming with Go

    first 24h programming with Go

    Because I had yesterday a long overlay at the airport in KL, I decided to use the time to learn a bit of programming…

  • No experience, no job!

    No experience, no job!

    In job applications the applicants are often asked about their work-experience. But how do you gain work-experience in…

社区洞察

其他会员也浏览了