Slide 1

Slide 1 text

Continuous Deployment to Build Trust CHRIS WELDON PRINCIPAL CONSULTANT IMPROVING ENTERPRISES

Slide 2

Slide 2 text

Chris Weldon u  Principal Consultant u  Microsoft MVP u  Slings Code in C# and PHP u  Systems Administrator devops u  [email protected] u  @neraath

Slide 3

Slide 3 text

And now for something completely different

Slide 4

Slide 4 text

As a conference presenter, I would like a web site with upcoming conferences, so I can stay in-the-know on the conference circuit.

Slide 5

Slide 5 text

As a conference presenter, I would like to see a list of upcoming conferences, so that I know what to submit presentations for.

Slide 6

Slide 6 text

Our Journey Current Continuous Deployments

Slide 7

Slide 7 text

On Modularity…

Slide 8

Slide 8 text

In Business

Slide 9

Slide 9 text

We Develop Software

Slide 10

Slide 10 text

When developing software…

Slide 11

Slide 11 text

We often try as a team…

Slide 12

Slide 12 text

But are often racing the clock…

Slide 13

Slide 13 text

So we rush Apps to Production.

Slide 14

Slide 14 text

This cycle repeats and we make Frequent Changes to Production.

Slide 15

Slide 15 text

And Our Apps Repeatedly Break

Slide 16

Slide 16 text

When stuff breaks… The business gets mad!

Slide 17

Slide 17 text

They start to see us as “rogues”

Slide 18

Slide 18 text

And institute gates to stop this “bad” activity

Slide 19

Slide 19 text

Gates are typically nothing more than

Slide 20

Slide 20 text

Why?

Slide 21

Slide 21 text

It’s about Trust.

Slide 22

Slide 22 text

How do we rebuild trust?

Slide 23

Slide 23 text

Back to basics.

Slide 24

Slide 24 text

We write software to support the business.

Slide 25

Slide 25 text

Or software is the business.

Slide 26

Slide 26 text

We need to adapt to changes in business needs.

Slide 27

Slide 27 text

We need to (rapidly) fix bugs.

Slide 28

Slide 28 text

We properly test first.

Slide 29

Slide 29 text

In order to maintain stability…

Slide 30

Slide 30 text

…we should have slow, continuous evolution of features.

Slide 31

Slide 31 text

So how do we support these goals?

Slide 32

Slide 32 text

Strive for technical excellence!

Slide 33

Slide 33 text

Remember to test!

Slide 34

Slide 34 text

We should constantly integrate all changes back into mainline.

Slide 35

Slide 35 text

requent Deployments Amount of Change Inf F

Slide 36

Slide 36 text

Automate Deployments

Slide 37

Slide 37 text

Our Journey Current Continuous Deployments Automation

Slide 38

Slide 38 text

Technical Excellence

Slide 39

Slide 39 text

Let’s talk about your databases…

Slide 40

Slide 40 text

As a conference organizer, I would like conferences I create to persist beyond my session so that other users can see upcoming conferences.

Slide 41

Slide 41 text

Is your DBA’s idea of SQL Management pitching him a SQL script to run?

Slide 42

Slide 42 text

That’s not automation.

Slide 43

Slide 43 text

Solution: Migrations u  Entity Framework Code-First Migrations u  Migrator.NET u  RoundhousE u  And many more…

Slide 44

Slide 44 text

       public  class  Conference          {                  public  int  Id  {  get;  set;  }                  [Required]                  public  string  Name  {  get;  set;  }          }

Slide 45

Slide 45 text

       public  partial  class  Initial  :  DbMigration          {                  public  override  void  Up()                  {                          CreateTable(                                  "dbo.Conferences",                                  c  =>  new                                          {                                                  Id  =  c.Int(nullable:  false,  identity:  true),                                                  Name  =  c.String(nullable:  false),                                          })                                  .PrimaryKey(t  =>  t.Id);                                            }                                    public  override  void  Down()                  {                          DropTable("dbo.Conferences");                  }          }

Slide 46

Slide 46 text

       public  class  Conference          {                  public  int  Id  {  get;  set;  }                  [Required]                  public  string  Name  {  get;  set;  }                  [Required]                  public  string  Description  {  get;  set;  }                  public  DateTime  StartTime  {  get;  set;  }                  public  DateTime  EndTime  {  get;  set;  }          }

Slide 47

Slide 47 text

       public  partial  class  DescriptionAndDates  :  DbMigration          {                  public  override  void  Up()                  {                          AddColumn("dbo.Conferences",  "Description",  c  =>  c.String(nullable:  false));                          AddColumn("dbo.Conferences",  "StartTime",  c  =>  c.DateTime(nullable:  false));                          AddColumn("dbo.Conferences",  "EndTime",  c  =>  c.DateTime(nullable:  false));                  }                                    public  override  void  Down()                  {                          DropColumn("dbo.Conferences",  "EndTime");                          DropColumn("dbo.Conferences",  "StartTime");                          DropColumn("dbo.Conferences",  "Description");                  }          }

Slide 48

Slide 48 text

Migrations Demo Demo

Slide 49

Slide 49 text

Configuration Management

Slide 50

Slide 50 text

As a systems administrator, I would like enable caching of conferences from the database so that we can minimize the impact of querying the database.

Slide 51

Slide 51 text

Scenario: Multiple web applications u  CritterMatch Core Business Libraries (CMCBL) u  CritterMatch.com depends on: u  log4net v1.0.6 u  Entity Framework v4 u  ASP.Net Web API v1.0.0 u  CMCBL v1.0.0 u  CritterMatch Business Services depends on: u  log4net v1.2.1 u  Entity Framework v5 u  ASP.Net Web API v1.2.2 u  CMCBL v1.1.0

Slide 52

Slide 52 text

NuGet

Slide 53

Slide 53 text

Scenario: Multiple web applications u  CritterMatch.com u  Developer Workstations u  Integration/QA u  Staging u  Production u  CritterMatch Business Services u  Developer Workstations u  Integration/QA u  Production – Client A u  Production – Client B

Slide 54

Slide 54 text

Configuration Management u  Configurations likely to change: u  Database Connection Strings u  Web Service Connection Endpoints u  Authorized Users? u  Requirements Management u  Different views or behaviors u  Dependency Injection? u  Often times a configuration change, too.

Slide 55

Slide 55 text

Configuration Management Strategies

Slide 56

Slide 56 text

                                                                                  web.config

Slide 57

Slide 57 text

web.config Transforms                                                                                                        

Slide 58

Slide 58 text

Logging and Monitoring Strategies

Slide 59

Slide 59 text

Better Know a Framework

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

PIC: Scaling

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

PIC: False Positive

Slide 65

Slide 65 text

Making Logging Useful to Ops & Engineering u  Ops needs to know: u  Network connection problems u  Load problems u  Service/dependency outages u  Consider surfacing events to event log for ops, leaving log files to devs u  Engineering needs to know: u  Everything that ops needs to know u  Performance

Slide 66

Slide 66 text

Debug is never for production u  Not constantly, that is. u  If you are trying to debug the production database query, you’re doing it wrong. u  If you are trying to figure out the object model being sent to the view, you’re doing it wrong. u  If you are trying to debug the workflow of your application, you’re doing it wrong. u  The highest level of constant production logging should be INFO. u  Info serves for interactions between customers and your site. u  Info surfaces information customers have requested, but never the interactions of your code.

Slide 67

Slide 67 text

Exception Management u  Don’t always surface exceptions to your Event Log if Ops is monitoring u  Boy Who Cried Wolf u  Be meticulous about which exceptions are surfaced out of your application u  Exceptions are expensive

Slide 68

Slide 68 text

Demo

Slide 69

Slide 69 text

During Deployments

Slide 70

Slide 70 text

Continuous Deployment = Release to Production After Every Commit?

Slide 71

Slide 71 text

We don’t want to be rogues…

Slide 72

Slide 72 text

Release Management u  How to manage multiple environments? u  Builds for Each Environment u  Versioning

Slide 73

Slide 73 text

devops u  The collaboration, communication, and integration between developers and operations to reduce the friction of getting software releases into production.

Slide 74

Slide 74 text

Production Push/Pull

Slide 75

Slide 75 text

CI Push

Slide 76

Slide 76 text

But how do we establish trust?

Slide 77

Slide 77 text

Our Journey Current Continuous Deployments Automation Testability

Slide 78

Slide 78 text

Unit Tests?

Slide 79

Slide 79 text

What about your UI?

Slide 80

Slide 80 text

What about dependency or component failure?

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

Smoke Tests!

Slide 83

Slide 83 text

Behavioral/Acceptance Tests

Slide 84

Slide 84 text

Gherkin Feature:  CreateConference   As  a  conference  organizer   I  would  like  to  create  a  conference   So  that  I  can  manage  the  details  of  the  conference.       Scenario:  Attempting  to  create  a  conference  without  times  throws  a  validation  error   Given  I  submit  the  Name  of  the  conference  as  AgileDotNet   When  I  create  the  conference   Then  I  should  get  a  validation  error     Scenario:  Creating  a  conference  with  name  and  times  creates  the  conference   Given  I  submit  the  Name  of  the  conference  as  AgileDotNet   And  I  submit  the  Description  of  the  conference  as            "Great  content  blending  the  world  of  Agile  with  DotNet  development"   And  I  submit  the  StartTime  of  the  conference  as  2013-­‐05-­‐17  08:00:00   And  I  submit  the  EndTime  of  the  conference  as  2013-­‐05-­‐17  18:00:00   When  I  create  the  conference   Then  I  should  get  the  status  code  Created  

Slide 85

Slide 85 text

[Given("I  submit  the  (.*)  of  the  conference  as  (.*)")]   public  void  GivenIHaveSubmittedConferenceInformation(string  field,  string  value)   {          var  conferenceType  =  typeof  (Conference);          var  fieldInfo  =  conferenceType.GetProperty(field);          if  (fieldInfo  ==  null)  throw  new  Exception("No  field  by  name  "  +  field  +  "  found.");            if  (fieldInfo.PropertyType  ==  typeof(DateTime))                  fieldInfo.SetValue(ConferenceToSubmit,  DateTime.Parse(value));          else                  fieldInfo.SetValue(ConferenceToSubmit,  value);   }

Slide 86

Slide 86 text

[When("I  create  the  conference")]   public  void  WhenICreateTheConference()   {          try          {                  Result  =  Controller.Post(ConferenceToSubmit);          }          catch  (Exception  e)          {                  Result  =  e;          }   }

Slide 87

Slide 87 text

[Then("I  should  get  the  status  code  (.*)")]   public  void  IShouldGetAStatusCode(string  statusCodeName)   {          Assert.IsInstanceOfType(typeof(HttpResponseMessage),  Result,  "Expected  an   HttpResponseMessage.");          var  message  =  (HttpResponseMessage)Result;          HttpStatusCode  statusCode;          Enum.TryParse(statusCodeName,  true,  out  statusCode);          Assert.AreEqual(statusCode,  message.StatusCode);   }

Slide 88

Slide 88 text

Strive for user scenario testing…

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

Still having trust issues?

Slide 91

Slide 91 text

Our Journey Current Continuous Deployments Automation Testability Manageable

Slide 92

Slide 92 text

Gated deployments

Slide 93

Slide 93 text

Rollback Techniques

Slide 94

Slide 94 text

Let’s see it!

Slide 95

Slide 95 text

Test labs

Slide 96

Slide 96 text

Behavior Driven Infrastructure

Slide 97

Slide 97 text

Our Journey Current Continuous Deployments Automation Testability Manageable Approvals

Slide 98

Slide 98 text

“Red Tape”

Slide 99

Slide 99 text

We want to be heroes…

Slide 100

Slide 100 text

But many of us are just a bunch of geeks…

Slide 101

Slide 101 text

How do we meet their needs?

Slide 102

Slide 102 text

How do we get everyone on board?

Slide 103

Slide 103 text

Take it one step at a time…

Slide 104

Slide 104 text

Our Journey Current Continuous Deployments Automation Testability Manageable Approvals

Slide 105

Slide 105 text

Recap

Slide 106

Slide 106 text

Q&A

Slide 107

Slide 107 text

Ratings, Please! http://spkr8.com/neraath