Continuous development and continuous integration from the testing perspective
2. 6. 2023
Continuous development continuous integration is the key aspect for the digitalization era in the software delivery. The need of market is to be as agile, fast and flexible as it gets in order to keep pace with the digitalization era. We would like to share our experience how to achieve CI/CD from the testing perspective in various areas of our software development.
We will have a look to various stages of testing in the ci/cd cycle :
- unit testing
- system testing
- deployment strategies
Unit testing
Unit tests are typically written by programmer during development phase of the project and they should test functionality of the components, services, workflows from the technical perspective. In the modern CDI/CD pipelines there is a defined test coverage which should be passed in order to start a build of the request.
For different areas of our software development we use different tools for unit testing.
For angular, we use jest testing and standard testing services for components, services using mockservices, testbed etc.
Typical test of the angular service can look like this :
import {ChatService} from './chat.service';
import {
AppScreen,
ChatItemDef,
ChatItemType,
SessionService,
Status
} from '../../core/session.service';
import {TestBed} from '@angular/core/testing';
import {TranslateService} from '@ngx-translate/core';
import {of} from 'rxjs';
import {BreakdownService} from '../../core/breakdown.service';
let ethStudy=2;
const IdentifyContactConstV: ChatItemDef[] = [{id: 'chat.first-name', type: ChatItemType.TXT_SINGLE, value: undefined}];
const FLAVOR_DEF = {
showIntro: true,
branding: 'high',
chat: {IdentifyContact: IdentifyContactConstV}
};
jest.mock('../../app-constants', () => ({
get IDLE_CHECK_INTERVAL() {
return 100;
},
get IDLE_MAX_WAIT() {
return 500;
},
get ETH_STUDY() {
return ethStudy;
},
get IDLE_TERMS_MAX_WAIT() {
return 555;
}
}));
describe('ChatService', () => {
let useMock = jest.fn().mockReturnValue(of({}));
let getStatusMock = jest.fn();
let errorCaseMock = jest.fn();
let getScreenMock = jest.fn();
let getFlavorDefMock = jest.fn();
beforeEach(() => {
TestBed.configureTestingModule ({
providers: [
{
provide: TranslateService,
useValue: {use: useMock,
instant: useMock}
},
{
provide: BreakdownService,
useValue: {
getStatus: getStatusMock,
errorCase: errorCaseMock
}
},
{
provide: SessionService,
useValue: {
flavorDef: FLAVOR_DEF,
status: Status.IdentifyContact
}
}
]}).compileComponents();
});
it('should initialize the chat service', () => {
let chat_service = TestBed.inject(ChatService);
expect(chat_service).toBeTruthy();
});
it('should start the chat', () => {
let sessionStatus = Status.IdentifyContact;
let serverFlavor = 'A1';
let startScreen = AppScreen.Intro;
let chat_service = TestBed.inject(ChatService);
getStatusMock.mockReturnValueOnce(of({
status: sessionStatus,
flavor: serverFlavor
}));
getScreenMock.mockReturnValue(startScreen);
getFlavorDefMock.mockReturnValue(FLAVOR_DEF);
chat_service.startChat();
expect(chat_service.chatEntries[0].type).toBe('bot');
expect(chat_service.chatEntries[0].id).toBe('chat.first-name');
expect(chat_service.lastAnswerIdx).toBe(-1);
});
});
For the java backend development we use also maven unit tests.
For the Siebel CRM development we decided to use Teamcity JUnit tests, which are executed once a day and these address workflows, business services, inbound outbound integrations, email configuration. We address some of these in our blog previously.
Here is some example from the daily execution of the junit tests from siebel crm :
Here is an example of the junit test fo siebel CRM for the outbound integration rest service :
This way we have either before export of the repository to the production or before build the software covered with testing and making sure working.
There are also cloud frameworks for code ci/cd pipeline such as AWS Code Pipeline. It is fully managed continuous delivery service that helps you automate your release pipelines for fast and reliable application and infrastructure updates. This solution uses CodePipeline to create an end-to-end pipeline that fetches the application code from CodeCommit, builds and tests using CodeBuild, and finally deploys using CodeDeploy.
System testing
For the system testing mostly bots which record usage pattern tracking behaviour (UPT) for the processes and user behaviours are used. Those frameworks then for defined UPT have variables which are provided as input and are used to create test records. For the interfaces stubs and mockups are used to cover integration endpoint if not in the system test provided. During this phase it is not intended to cover e2e testing. Typically we used these frameworks before every release to the production and after code freeze phase. It can be also executed on daily bases as this is fully automated.
For siebel CRM there is a typical test automation toolkit based on jenkins, selenium , upt . This topic is very wide and complex and it is not intended to in this blog to cover it fully.
CI/CD deployment stategies
It is very important for the CI/CD to have automated deployment strategy and testing of the deployment. It is also important to have automated installation, provisioning and patching of the enviroments.
For various purposes and deployments there are specialized tools. For patching it is interesting to point out fully autonomous oracle db and oracle autonomous linux cloud services from the OCI , which are fully managed, secure with zero downtime patching.
We have very good experience with ansible tower ci/cd toolfor siebel CRM automated installation.
For the deployment there are very interesting deployment strategies to ensure zero downtime and to make sure only good software is left in the production
- Blue/green deployment
- Canary deployment
- Linear deployment
- All-at-once deployment
Conclusion
For every stage of the software development with the CI/CD approach it is very important choose right approach , technique and tooling . In the beginning of the development it means more time and action but generally it ensures good quality, fast time to market and sabing of cost . Selection of infrastructure, tooling, technique and automation is the key for successfull CI/CD . Nowdays if the cloud is selected option it contains the best state of the art from CI/CD from developers for developers.
Back to Blog