Running production tests

The process for running production tests is the same as functional testing we executed earlier. The difference is in the tests we execute, not how we do it.

The goal of production tests is not to validate all the units of our application. Unit tests did that. It is not going to validate anything on the functional level. Functional tests did that. Instead, they are very light tests with a simple goal of validating whether the newly deployed application is correctly integrated with the rest of the system. Can we connect to the database? Can we access the application from outside the cluster (as our users will)? Those are a few of the questions we're concerned with when running this last round of tests.

The tests are written in Go, and we still have the golang container running. All we have to do it to go through the similar steps as before.

 1  kubectl -n go-demo-3-build 
 2      exec -it cd -c golang -- sh
 3
 4  export ADDRESS=$(cat prod-addr)

Now that we have the address required for the tests, we can go ahead and execute them.

A note to Docker for Mac or Windows users
DNS behind Docker for Mac or Windows is localhost. Since it has a different meaning depending on where it is invoked, the tests will fail, just as they did with the functional stage. Please change the address to api.go-demo-3:8080. This time we need to specify not only the name of the Service but also the Namespace since we are executing tests from go-demo-3-build and the application is running in the Namespace go-demo-3. Please execute the command export ADDRESS=api.go-demo-3:8080.
 1  go test ./... -v --run ProductionTest

The output of the command is as follows.

=== RUN   TestProductionTestSuite
=== RUN   TestProductionTestSuite/Test_Hello_ReturnsStatus200
--- PASS: TestProductionTestSuite (0.10s)
    --- PASS: TestProductionTestSuite/Test_Hello_ReturnsStatus200 
(0.01s)
PASS ok _/go/go-demo-3 0.107s
A note to GKE users
If your tests failed, the cause is probably due to a long time GKE needs to create a load balancer. Please wait for a few minutes and re-execute them.
Figure 3-6: The production testing stage of a continuous deployment pipeline

Production tests were successful, and we can conclude that the deployment was successful as well.

All that's left is to exit the container before we clean up.

 1  exit
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.20