How to approach CI

I am creating a company from scratch (Tomcat + Spring Rest + Java), so we have the opportunity to do something right (or not to repeat our past mistakes in the list), one of the goals that we do want to achieve is the ability to automatically build , test (unit, integration) and deploy.

Our platform is built with one static HTML / JS interface site hosted by NGiNX and several API servers (different applications), some of them are open, and some of them are only available inside the farm by open API applications.

I chose TeamCity as the CI server since I am a little familiar with it, and so far I have had excellent experience with all Jetbrain products.

so far i have defined two build configurations

  • Development prudence: it checks from git, runs DB scripts to prepare the database, fulfills the maven goals of a clean installation (therefore, our test package is executed), performs code coverage and static code analysis. This configuration is excellent.

  • Integration: checks from git, runs DB scripts to prepare the database, performs maven goals of a clean install (therefore, our test package runs)

Now that I am facing a problem, our configuration requires several .war files that will be deployed on different machines before Integration testing starts, I would also like to build it so that I can add a third configuration that will be deployed to real-time after the integration has completed, so that it basically does the same as the second configuration, but adds some features, such as removing the application and re-inclusion in it when it has been deployed gracefully , I saw several approaches to how to do this from maven cargo, shell scripts, fabrics, etc.

Is there a recommended way to approach this drawing from your past experience? also I don’t understand what is the best way to run integration testing, which involves several deployment applications, I have seen many examples of built-in berths, etc., but this is only good for a single application or a very simple configuration when you need 3- 4 applications that will be deployed before you can start testing, what is the best way to do this? add another integration testing project and complete another maven goal with a specific profile after deployment is complete?

BTW - Deployment in AWS

Thanks guys.

+6
source share
1 answer

First of all, I strongly recommend you read Continuous Delivery (Jez Humble, David Farley), he got a ton of information about it. Here is a sample chapter .

As I read this, I started implementing an assembly pipeline, where each svn commit goes through every stage in the pipeline, when the environment gradually becomes more like a production process as the assembly advances. For this we use Jenkins.

  • Stage of fixation - dev sanity - compile, unit test and some indicators. This initial step also creates the binaries needed for the rest of the pipeline
  • The integration stage is the same files as the previous stage (not a new check) and performs tests of db integration into memory
  • Automated Acceptance Testing Phase - takes binary files from the commit phase and deploy to the server where we run selenium tests
  • QA stage - this is deployed by qa, which simply presses a button to pull whatever they want, again it simply deploys the binaries from the commit phase to the QA server.
  • UAT is the same as QA, but a more productive environment where we also run performance tests
  • Products - takes binary files from the commit phase and deploys for production.

Each of these stages acts as a “quality shutter” - the assembly is not allowed to move on until it passes a certain threshold value - testing errors,% s metric, etc. Some stages of the flow are automatically automatically started manually. Any configuration changes necessary for each environment are performed by unpacking the source binary files, changing the settings, packing them again - ideally, I would like to separate the configuration from the application binaries, but have not yet found a way to do this.

The automatic acceptance test script simply updates the existing application on the server - the qa stage performs a complete stop, uninstall, installation and start. Each of them runs a different script - a combination of ant and python.

Here's what the pipeline looks like in jenkins with the assembly pipeline plugin.

[edit]

In fact, you do not need to complete each stage of this at a time, it’s easy enough to have place holders for each stage, which simply flow to the next, without actually doing anything. If you map your current process, you can automate parts of it and gradually move on to the pipeline.

The most successful commit step is what you would do when setting up a regular CI server, create a project, connect it to version control, compile, run tests, run some statistics from ant / maven. It takes a little over 5 minutes.

The statistics task takes too much time (> 15 minutes), so I run a subset on a commit and do a night run, which does all the work of Findbugs, PMD, Checkstyle and Cobertura. I would rather run all this while committing, but this would require some more equipment and work on setting up some kind of assembly grid.

Selenium tests are not currently in a separate project, but they are packaged as a separate jar, and it becomes available for the automated acceptance testing stage through the jenkins 'copy artifact' plugin - ant / python scripts pack the WAR file and are deployed in the container, then ant is unpacked and runs the Selenium tests (via junit). At the moment there is only a bunch of "smoke tests" and they are not dependent on the main WAR, although I can see this change. I don’t like the idea of ​​having separate projects for code and tests - build scripts just pack the classes and libraries needed for each module from the main project - for your situation (and soon ours) you may have to do something else - how about starting a virtual machine or two with the necessary configuration and its deployment. (a lot of information in the continuous delivery book about this)

It's good that Jenkins supports this a lot through plugins - we switched from Atlassian Bamboo, because most of what we wanted was not available, and the existing plugins either did not work or were not compatible with the Bamboo version. I have not used Team City for a while, so I have no idea if this supports the idea of ​​a “pipeline” [aparently not] . The Build Pipeline plugin is quite new and has a few rough edges, but is under active development - I think that it is possible to do this with the help of advanced Jenkins compilations and assembly of trial stones, but they did not try to do it. If you have enough resources (money!), You can look at Go

+4
source

Source: https://habr.com/ru/post/903113/


All Articles