Integ Testing

To further strengthen our confidence in the software we're developing, we'll run a set of end-to-end tests in an environment resembling real-world conditions - that's what integration testing is about.

Our CLI tool fetches and de-serializes the ElasticSearch JSON greeting from the default ElasticSearch endpoint /. For our integ test, we need a running instance of ElasticSearch.

Creating a Staging Environment

Concourse plugs in well into the docker ecosystem. Luckily, Elastic publish every release of ElasticSearch in Docker, so we can reuse those.

To run a basic unsecured ElasticSearch instance, run the following:

docker run -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.4.3 /usr/share/elasticsearch/bin/elasticsearch -Expack.security.enabled=false -E discovery.type=single-node

And after a while the ElasticSearch endpoint becomes available for curling:

$ curl http://localhost:9200
{
"name" : "8d0c907f9591",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "TTV_a-IHStS_J7qQb-1spQ",
"version" : {
"number" : "8.4.3",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "42f05b9372a9a4a470db3b52817899b99a76ee73",
"build_date" : "2022-10-04T07:17:24.662462378Z",
"build_snapshot" : false,
"lucene_version" : "9.3.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}

Now we can use our utility against it:

$ ./fetch http://localhost:9200
ElasticSearch Greeting Fetch
{Name:8d0c907f9591 ClusterName:docker-cluster ClusterUuid:TTV_a-IHStS_J7qQb-1spQ
VersionInfo:{BuildDate:2022-10-04T07:17:24.662462378Z BuildFlavor:default
BuildHash:42f05b9372a9a4a470db3b52817899b99a76ee73 BuildSnapshot:false
BuildType:docker Int:8.4.3 LuceneVersion:9.3.0 MinimumIndexCompatibilityVersion:7.0.0
MinimumWireCompatibilityVersion:7.17.0} Tagline:You Know, for Search}

We have all ingredients for an integration test:

  • a binary we're about to test as an output from the build job
  • a running instance of ElasticSearch
  • a set of outputs expected after running our binary against ES

Let's put them together in a task.