Sailing through devlopment with legacy code

Preview:

Citation preview

Legacy code yet Agile way…A journey we started!!!

Speakers:-

Prasad Kunte @prasad_kunteNaresh Jain @nashjain

Hello

About IDeaS

25+ YEARS 7000+ CLIENTS 1M+ ROOMS 94 COUNTRIES 95% +

ago we started helping clients manage their revenue

later we’re still finding the revenue opportunity in every situation

around the world are priced every single day using IDeaS

on 6 continents have hotels that now run on IDeaS Revenue Management Systems

More than 95 percent of all our clients are still working with us today.

• Developed & rolled out in 2007• Mainly into maintenance untill last year• Conducive market to pick this business since last year

CPRMS Product

• New Specifications for Inbound Data – Transactional data instead of summry data

• New Forecasting Methodology for better forecasting• Other New features

Business Requirements

& came the first surprise…

• Crashed CVS Repo Server• An opportunity to migrate to SVN….

– We chose SVN http://cvs2svn.tigris.org/

• 0 Running Test Cases

• No CI/CD

• Production Schema/Seed not base lined in code base• Old Stack

– Junit 1.5

– Spring 2.0.5

– Ant

The Legacy

Agile engineering practices

Safety Netting to Legacy Code

Dev. SetupCI/CD

Test Pyramid

Clean Code

Need to have all of it…

Safety Netting to Legacy Code

Dev. Setup

CI/CD Env

Test Pyramid

Clean Code

We need all of it

Don’t Forget Mate,

Business is waiting for new

features!!!

Ooops…… Which one to take first

Safety Netting to Legacy Code

Dev. Setup

CI/CD Env

Test Pyramid

Clean Code

12 3 4 5

Just like Product Backlog,we have Agility Backlog

Sprint 0 – Backlog Prioritization

Safety Netting to Legacy Code

Dev. Setup

CI/CD Env

Test Pyramid

Clean Code

1

2

3

4

5

• Spiked out Workflow tests• Removed un-necessary out dated items from SVN –

– Design Docs (HLD, LLD)

– Prototype HTMLs

– EAP project files

– Multiple JBOSS file check-ins

– MySQL cooked up data files

Reduced the code base size (from 2.1 GB to 500 MB)• Spiked out Jenkins spin up and local build

The most important!!!

• Should we copy pase code for new specifications? --- Don’t think so

• Workflow Tests for Old Specs– Ensured no existing functionality breaks– Still not database agnostic

• Tests to run locally on a populated database

Ensure support to

existing client

The 2nd most important… A feedback loop!

• Jenkins

I am here to help you guys!

Build Jobs for Local and Jenkins

Local Build

CI Build

CT Deploy

Workflow Tests

Jenkins is Ready to give quick feedback

Next one – Safety Netting

• Unit Tests– Independent isolated tests – Tests individual class/function/method

• Business Logic Tests –– Validates a core business rule. – Might span across multiple domain objects/functions

• Workflow Tests – 1 for each Scenario in New Spec

Safety Netting as we move

along

• Refactor the code as we modify it

• Write unit & business logic tests if they don’t exist

• Don’t add 1 more if else to 10 existing if else(s)

Next is Test Pyramid

• Right Tests for getting right feedback• Avoiding test duplication• Avoid 100s of UI Tests – they are not needed as other layers

can catch most of it

Wait a second!

We’ve started building 3 layers already

3 layers already there…

• https://wiki.jenkins-ci.org/display/JENKINS/LabeledTestGroupsPublisher+Plugin• Test Groups: "unit", "smoke", "regression", "integration", "special", "misc“

Image source: http://www.ascendfinancialplanning.com/your-finances-are-like-the-game-of-football-do-you-have-a-game-plan

Well!! Then, we need to monitor it!

We do have a plugin

• Unit, Business Logic, Integration, Workflow, End to End, UI• Code and hpi available @ https://github.com/prasadkunte/labeled-test-groups-

publisher• Now, we can configure & see tests on Jenkins like this

Lets change labels as per our pyramid

Labelled Test Group – in Action

You can keep business happy while we pay tech. debt.

Safety Netting to Legacy Code

Dev. SetupCI/CD Env

Test Pyramid

Clean Code

& this is what we started already!!!!!

Dev setup is the next You guys are

meeting the business needs,

that’s cool!!

Dev. Setup• Dev. Setup pushed on to Artifact Repo. – Java, Jboss, MySQL

• Baseline database– Structure copied from Prod– Seed data identified– Ant Script using dbdeploy to deploy base lined database

Dev. Setup

• Custom Tool to get trimmed DB – For Workflow Tests

Workflow test cases – Not database agnostic

Hackathon @ IDeaS

• Restified the app exposing few apis

• Workflow Test Cases Refactored – Database Agnostic

• Before

• After

Dev setup in good shape too

Safety Netting to Legacy Code

Dev. Setup CI/CD EnvTest Pyramid

Clean Code

We are going to improve further!!!

JaCoCo wrapper for test results

Clean Code - Sonar Integration

Write Selenium UI tests only for important screens –The 4th Layer…

• Integration with Jenkins pending• Taking around 1 min to cover 8 screens

Another Layer in Test Pyramid - Selenium UI Test

So far, what did we achieve?

• From no safety net To some safety net for legacy code• From no CI/CD To Jenkins CI/CD• From no test pyramid To 4 layers of pyramid (3 integrated in CI)• From no standard dev set up To standard dev setupWhile committing to Business Requirements

http://www.strongautomotive.com/everyone-good-plan-get-punched-nose/

Road ahead…

Keep Improving:-1. Increase Test

Coverage %2. Reduce

Violations3. Reduce build

timings4. Fully Automate

Production Deployment

Moving Forward | Test Coverage & Viloations

– Sonar Violations - Spend 20 minutes a day,

– 5 tests a week – Refactor as we move

– 1 UI Test a week

Page 31

Earlier

Latest

Moving Forward | Reduce Build Timings – Faster Feedback Loop

Moving Forward | Auto Deployments

& the journey continues….

© Copyright Integrated Decisions and Systems, Inc. (IDeaS – A SAS COMPANY)

Visit IDeaS online at www.ideas.com

Thank you so much!

Speakers:

Naresh Jain @nashjain

Prasad Kunte @prasad_kunte

© Copyright Integrated Decisions and Systems, Inc. (IDeaS – A SAS COMPANY)

Visit IDeaS online at www.ideas.com

Few References• http://blogs.agilefaqs.com/2011/02/01/inverting-the-testing-pyramid/• https://prasadkunte.wordpress.com/2014/12/14/restifying-a-legacy-application-

an-experience/• http://blogs.agilefaqs.com/2011/03/09/big-upfront-test-creation-in-legacy-

code-is-a-bad-idea/• https://www.atlassian.com/company/about/shipit• http://www.mkyong.com/webservices/jax-rs/jersey-spring-integration-example/• http://examples.javacodegeeks.com/enterprise-java/rest/jersey/json-example-

with-jersey-jackson/

© Copyright Integrated Decisions and Systems, Inc. (IDeaS – A SAS COMPANY)

Visit IDeaS online at www.ideas.com