ChatOps journey with Ansible, Hubot, AWS and Windows - Part 3

This is Part 3 of the series of setting up a Chatbot for deploying artifacts to AWS EC2 Windows instances. In this post, I’ll discuss using AWS Lambda to make sure instances are not left running for too long to save money.

The Chatbot makes deployment much easier and encourages developers to run more tests. However, those launched instances are more likely to be left running for a long time. The situation is worse for Windows instances, which are way more expensive that Linux instances ($0.15 comparing to $0.03). So I need a way to terminate those instances when not used.

Read More

ChatOps journey with Ansible, Hubot, AWS and Windows - Part 1

Comparing to DevOps, ChatOps, a word coined by GitHub, is trying to leverage Chatbots to make developers’ life much easier. Comparing to CLI or web pages, ChatBots are more user-friendly to interact with, and bots are COOL!!!

This series of posts takes you through the process of setting up a Chatbot for deploying artifacts to AWS EC2 Windows instances. Tools and services used in this post include:

This series assumes you have basic knowledge of Ansible and Docker. If not, you should start from tutorials for these two.

Update 2018-02-08: Use 7zip to extract tar.gz files.

Read More

Spring 5 WebFlux functional programming model

Spring 5 has the new module WebFlux to create reactive web applications. Spring WebFlux supports two programming models: traditional annotation-based programming model and functional programming model. In this post, we’ll going to scratch the surface of the new functional programming model. This post assumes that you already know concepts like Flux and Mono in Reactor.

We’ll use a calculator service as the example. This service supports operations like add, subtract, divide and multiply with two operands. The parameter operator specifies the operation to call, while parameters v1 and v2 specify the two operands. For example, the url /calculator?operator=add&v1=1&v2=2 invokes the add operation with values 1 and 2.

Read More

Clean up disk space of Docker for Mac

After running Docker for Mac for a long time, Docker keeps eating up disk space. Even though the containers and images are removed, the disk space is not reclaimed. The problem is the file /Users/<username>/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2 is too big. For my Mac, this file is about 46G. This is actually a known issue tracked in this GitHub issue. So far, we only have a workaround to fix this issue.

Before applying this workaround, you should try docker system prune to remove unused data.

Read More

JUnit 5 assumptions

Assertions verify that expected conditions are met after some executions. In some cases, the assertions may not even be necessary to run. This means that assertions can have assumptions. JUnit 5 provides static methods in the class org.junit.jupiter.api.Assumptions to describe test assumptions. When the assumption is not valid, the org.opentest4j.TestAbortedException is thrown and the test is aborted. There are three groups of static methods in Assumptions, assumeTrue, assumeFalse and assumingThat.

Read More

JUnit 5 dynamic tests

In JUnit 5, we can create dynamic tests that are generated at runtime by factory methods. These methods are annotated with the annotation TestFactory.

The method annotated with @TestFactory must return a Stream, Collection, Iterable, or Iterator of DynamicNode objects. DynamicNode is abstract. It has two subclasses, DynamicContainer is the container of other DynamicNode objects; DynamicTest is a generated test case. DynamicTest is created from a display name and an Executable object. Executable is a functional interface that contains only one method void execute(). DynamicContainer is created from a display name and a collection of DynamicNodes.

Read More