37
Legacy code yet Agile way… A journey we started!!! Speakers:- Prasad Kunte @prasad_kunte Naresh Jain @nashjain

Sailing through devlopment with legacy code

Embed Size (px)

Citation preview

Page 1: Sailing through devlopment with legacy code

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

Speakers:-

Prasad Kunte @prasad_kunteNaresh Jain @nashjain

Page 2: Sailing through devlopment with legacy code

Hello

Page 3: Sailing through devlopment with legacy code

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.

Page 4: Sailing through devlopment with legacy code

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

CPRMS Product

Page 5: Sailing through devlopment with legacy code

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

• New Forecasting Methodology for better forecasting• Other New features

Business Requirements

Page 6: Sailing through devlopment with legacy code

& came the first surprise…

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

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

Page 7: Sailing through devlopment with legacy code

• 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

Page 8: Sailing through devlopment with legacy code

Agile engineering practices

Safety Netting to Legacy Code

Dev. SetupCI/CD

Test Pyramid

Clean Code

Page 9: Sailing through devlopment with legacy 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!!!

Page 10: Sailing through devlopment with legacy code

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

Page 11: Sailing through devlopment with legacy code

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

Page 12: Sailing through devlopment with legacy code

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

Page 13: Sailing through devlopment with legacy code

The 2nd most important… A feedback loop!

• Jenkins

I am here to help you guys!

Page 14: Sailing through devlopment with legacy code

Build Jobs for Local and Jenkins

Local Build

CI Build

CT Deploy

Workflow Tests

Page 15: Sailing through devlopment with legacy code

Jenkins is Ready to give quick feedback

Page 16: Sailing through devlopment with legacy code

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)

Page 17: Sailing through devlopment with legacy code

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

Page 18: Sailing through devlopment with legacy code

Wait a second!

We’ve started building 3 layers already

Page 19: Sailing through devlopment with legacy code

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

Page 20: Sailing through devlopment with legacy code

Labelled Test Group – in Action

Page 21: Sailing through devlopment with legacy code

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!!

Page 22: Sailing through devlopment with legacy code

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

Page 23: Sailing through devlopment with legacy code

Dev. Setup

• Custom Tool to get trimmed DB – For Workflow Tests

Page 24: Sailing through devlopment with legacy code

Workflow test cases – Not database agnostic

Page 25: Sailing through devlopment with legacy code

Hackathon @ IDeaS

• Restified the app exposing few apis

• Workflow Test Cases Refactored – Database Agnostic

• Before

• After

Page 26: Sailing through devlopment with legacy code

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!!!

Page 27: Sailing through devlopment with legacy code

JaCoCo wrapper for test results

Clean Code - Sonar Integration

Page 28: Sailing through devlopment with legacy code

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

Page 29: Sailing through devlopment with legacy code

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

Page 30: Sailing through devlopment with legacy code

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

Page 31: Sailing through devlopment with legacy code

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

Page 32: Sailing through devlopment with legacy code

Earlier

Latest

Moving Forward | Reduce Build Timings – Faster Feedback Loop

Page 33: Sailing through devlopment with legacy code

Moving Forward | Auto Deployments

Page 34: Sailing through devlopment with legacy code

& the journey continues….

Page 35: Sailing through devlopment with legacy code

© 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

Page 36: Sailing through devlopment with legacy code

© 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/

Page 37: Sailing through devlopment with legacy code

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

Visit IDeaS online at www.ideas.com