Chuan Chuan Law

Software Automation | Continuous Integration | Continuous Delivery

Docker – Using Tiller To Overwrite Environment Specific Variables

To use Tiller, in Dockerfile, we specify: ADD deploy/tiller/*.yaml /etc/tiller/ ADD deploy/tiller/environments/dev /etc/tiller/environments/ ADD deploy/tiller/templates/* /etc/tiller/templates/ Tiller folder comprises of the following: environments This is where the yaml for environment specific variables are written: #These are the variables to overwrite service.conf.erb template service.conf.erb: target: /etc/appleapi/application.ini config: environment_name: “prod” #These are the variables to overwrite template.conf.erb template […]

Docker – How To Run A Debian Package In Docker

Below are the major steps on how to run a Debian package in Docker Dockerfile Download your Debian file # Download .deb fileRUN wget $debian_url \ && sudo dpkg -i appleapi.deb \ && apt-get install -f Using Ruby Tiller to overwrite environment specific configs (optional) #Tiller RUN sudo apt-get update && sudo apt-get -y install ruby RUN gem […]

Pact – Writing Consumer Test For OAuth2

OAuth2 uses Faraday to make HTTP requests. The Authorization in the Header is actually encoded using Base64. When we make requests using 3rd party tool such as Postman, this is not a issue. Therefore, your consumer test should look like this: apple_service.given(“the authnz provider is up”). upon_receiving(“a post token”). with(method: :post, path: ‘/token’, headers: {‘Content-Type’ […]

How To Setup Json Log in Logback

In pom.xml, add the dependency <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.6</version> </dependency> 2. In logback.xml, add the LogstashEncoder appender  <appender name=”JSON” class=”ch.qos.logback.core.rolling.RollingFileAppender”> //This is the JSON formatter <encoder class=”net.logstash.logback.encoder.LogstashEncoder” /> //This is where the JSON log will be produced <file>${catalina.base}/logs/webapp.log.json</file> //On a daily basis, the JSON logged will be rolled over <rollingPolicy class=”ch.qos.logback.core.rolling.TimeBasedRollingPolicy”> <fileNamePattern>${catalina.base}/logs/webapp.log.json.%d{yyyy-MM-dd}</fileNamePattern> //We only store […]

Pact – How To Set Up Provider In Play Framework

In build.sbt, import the plugin import au.com.dius.pact.provider.sbt._ SbtProviderPlugin.config ++ Seq( providers := Seq( ProviderConfig(name = “Provider”, port=49600, requestFilter = Some(request => request.addHeader(“Authorization”, “Bearer NTY5YjQwNGQtYjFkMi00N2UyLThiODgtYzQzNzBkNzlkMDQ5”) )).hasPactWith(ConsumerConfig(name = “TestConsumer”, pactFile = file(“spec/pacts/test-consumer.json”))) ) ) 2. In a Makefile, have the following task: run-provider: make run-app & \ sleep 60 sbt pactVerify Where run-app is another Makefile task […]

Pact – Asserting The Function To Test from App Level

In your consumer test class, instead of calling the “subject.methodToTest()”, For example: describe MethodToTest{ before do         AppleServiceClient.base_uri ‘localhost:1234’     end   subject { AppleServiceClient.new }   describe “get_an_apple” do     before do         apple_service.given(“an apple exists”).         upon_receiving(“a request for an apple”).         with(method: […]

How To Setup Pact Broker

Setting up Dockerized Pact Broker The easiest and fastest way to do this is via Dockerized Pact Broker. By following Step 1 to Step 4 in this document, you will be able to have a Dockerized Pact Broker linking to a Dockerized PSQL in your localhost within minutes! All you then need is to publish the JSON […]

Hello from New York!

G’day! I haven’t been blogging for a while. This is because I have been busy settling in the Big Apple! It was a big move and I have been very blessed to have the opportunity to explore the other side of the world. I look forward to continue sharing what I have learned here. 🙂 […]

Solving Peer Not Authenticated Issue for Maven repository on AWS

Below the problem I got while migrating the Jenkins slave jobs over to AWS:     The way I solve it is to get a copy of compiled dependencies on the AWS instance and build a AMI image out of it. So, the AWS instance will already have a copy of all needed dependencies, and […]

Getting Your Tests Into CI – Jenkins

Test automation is not complete without CI –  getting it running automatically on a build box. I will show how to get a Selenium test suite running on Jenkins which I have been using personally. I will assume you have already got Jenkins installed: 1. Click on New Item. Give the item a name and […]

« Older posts

© 2017 Chuan Chuan Law

Theme by Anders NorenUp ↑