Unit 4 - Notes

CSE121

Unit 4: DevOps & Software Testing

1. Introduction to DevOps

DevOps is a set of practices, tools, and a cultural philosophy that automates and integrates the processes between software development (Dev) and IT teams (Ops). It emphasizes team empowerment, cross-team communication and collaboration, and technology automation.

Key Goals:

  • Shorten the systems development life cycle.
  • Provide continuous delivery with high software quality.
  • Faster time to market.
  • More dependable releases.

2. DevOps Vs Traditional Software Development Models

Traditional models (Waterfall) and early iterative models (Agile) differ significantly from DevOps regarding team structure and deployment speed.

Feature Waterfall Model Agile Model DevOps
Approach Sequential/Linear phases. Iterative and incremental. Continuous collaboration and automation.
Team Structure Siloed teams (Dev, QA, Ops are separate). Cross-functional Dev & QA, but Ops is often separate. Dev, QA, and Ops work as a single integrated team.
Feedback Feedback arrives only at the end of the lifecycle. Feedback after every sprint (2-4 weeks). Instant/Continuous feedback via automated monitoring.
Deployment "Big Bang" deployment (rare, risky releases). Frequent releases, but deployment may still be manual. Continuous Deployment (automated, frequent, low-risk).
Focus Process and documentation. Customer satisfaction and software adaptability. End-to-end delivery pipeline and automation.

3. The DevOps Life Cycle

The DevOps lifecycle is often represented as an infinity loop, symbolizing continuous collaboration and improvement.

  1. Plan: Define business value and requirements.
  2. Code: Software design and code development using Git.
  3. Build: Managing versions and compiling code (using tools like Maven).
  4. Test: Automated testing to ensure quality (using Selenium).
  5. Release: Managing, scheduling, and controlling the build updates.
  6. Deploy: Automating the release into production (using Docker/Kubernetes).
  7. Operate: Managing the software during its production life (using Ansible/Puppet).
  8. Monitor: Identifying issues in specific releases and infrastructure (using Nagios).

4. Role of Automation in DevOps

Automation is the core principle of DevOps. It removes manual intervention, reducing human error and increasing speed.

  • Consistency: Automated scripts ensure the infrastructure is provisioned exactly the same way every time.
  • Speed: Machines execute tests and deployments faster than humans.
  • Scalability: Automation allows teams to manage thousands of servers as easily as ten.
  • Reliability: Self-healing scripts can restart failed services automatically.

5. CI/CD (Continuous Integration / Continuous Delivery)

CI/CD is the backbone of modern DevOps operations.

  • Continuous Integration (CI):
    • Developers frequently merge code changes into a central repository (Git).
    • Automated builds and tests run immediately to validate the changes.
    • Goal: Detect errors quickly.
  • Continuous Delivery (CD):
    • Code changes are automatically built, tested, and prepared for a release to production.
    • It requires a manual approval to deploy to the live environment.
  • Continuous Deployment:
    • Extends Continuous Delivery. Every change that passes all stages of your production pipeline is released to your customers automatically.

6. DevOps Tools

A "Toolchain" is used to achieve the DevOps lifecycle.

Source Code Management (SCM)

  • Git: A distributed version control system. It tracks changes in source code, enabling multiple developers to work together. It maintains a history of changes (commits) and allows branching and merging.

Build Tools

  • Maven: A build automation tool primarily used for Java projects. It manages project dependencies (libraries), compiles source code, runs tests, and packages the code into JAR/WAR files.

Containerization & Orchestration

  • Docker: A platform for developing, shipping, and running applications in "containers." Containers package the code with all its dependencies (libraries, runtime), ensuring it runs the same on a developer's laptop as it does on a production server.
  • Kubernetes (K8s): An open-source system for automating the deployment, scaling, and management of containerized applications (orchestration). If Docker creates the container, Kubernetes manages a cluster of hundreds of containers.

Configuration Management

  • Puppet: A model-driven configuration management tool. It uses a "Pull" model where agents on servers poll the master server for configuration updates. It ensures the state of the server matches the defined state (e.g., ensuring a web server is installed).
  • Ansible: An open-source IT automation engine. It uses a "Push" model (agentless). It connects to nodes via SSH and pushes out small programs called "modules" to configure the system. It is generally considered easier to learn than Puppet.

Testing

  • Selenium: A portable framework for testing web applications. It provides a playback tool for authoring functional tests without the need to learn a test scripting language (Selenium IDE) and a test domain-specific language (Selenese).

Monitoring

  • Nagios: A monitoring system that checks the status of servers, networks, and applications. If a system goes down or disk space runs low, Nagios sends alerts to the technical staff.

7. Fundamentals of Software Testing

Software Testing is the process of evaluating and verifying that a software product or application does what it is supposed to do. The benefits include preventing bugs, reducing development costs, and improving performance.

Verification vs. Validation

  • Verification: "Are we building the product right?" (Checking documents, design, code reviews).
  • Validation: "Are we building the right product?" (Checking if the actual software meets the user's needs).

8. Objectives of Testing

  1. Finding Defects: The primary goal is to identify errors or gaps contrary to requirements.
  2. Gaining Confidence: Ensuring the system is reliable before release.
  3. Preventing Defects: finding errors early in the development phase reduces the cost of fixing them.
  4. Information Provider: Providing stakeholders with information about the quality of the product.
  5. Compliance: Ensuring the software meets legal or industry standards.

9. Types of Testing

Functional Testing (What the system does)

  • Verifies that each function of the software application operates in conformance with the requirement specification.
  • Examples: Unit Testing, Smoke Testing, Sanity Testing, Regression Testing.

Non-Functional Testing (How the system behaves)

  • Checks aspects of the application that are not related to specific behaviors or user actions.
  • Examples:
    • Performance Testing: Load and Stress testing.
    • Security Testing: Checking for vulnerabilities.
    • Usability Testing: User-friendliness.

10. Levels of Testing

Testing is done in layers, moving from the smallest components to the full system.

  1. Unit Testing: Testing individual components or modules of source code (e.g., testing a single function in a class). usually done by Developers.
  2. Integration Testing: Testing the interaction between integrated units/modules to detect interface defects.
  3. System Testing: Testing the complete, integrated software to verify it meets specifications.
  4. Acceptance Testing (UAT): Performed by the client/user to verify the system meets business requirements before going live.

11. Manual Vs Automation Testing

Feature Manual Testing Automation Testing
Definition A human tester plays the role of the user and manually executes test cases. Uses tools and scripts to execute test cases.
Accuracy Prone to human error (fatigue, oversight). High accuracy; performs exactly what the script says.
Speed Time-consuming and slow. significantly faster execution.
Exploratory Best for exploratory, usability, and ad-hoc testing. Cannot do exploratory testing; only checks pre-defined paths.
ROI Lower ROI for long-term projects (high recurrent labor cost). Higher ROI for long-term projects (script created once, run many times).
When to use Short-term projects, UI changes frequently. Regression testing, Load testing, Stable projects.

12. Introduction to Test Case Design

A Test Case is a document which has a set of variables or conditions under which a tester determines whether a system under test satisfies requirements or works correctly.

Standard Test Case Format:

  1. Test Case ID: Unique identifier.
  2. Test Scenario: What you are testing (high level).
  3. Pre-requisites: What must be done before the test (e.g., User must be on the homepage).
  4. Test Steps: Detailed actions.
  5. Test Data: Inputs provided.
  6. Expected Result: What should happen.
  7. Actual Result: What actually happened.
  8. Status: Pass/Fail.

Simple Example: Login Functionality

  • Test Case ID: TC001
  • Scenario: Verify successful login with valid credentials.
  • Pre-requisite: User is on the login page.
  • Steps:
    1. Enter valid username "user@example.com".
    2. Enter valid password "Password123".
    3. Click "Login" button.
  • Expected Result: System should redirect user to the Dashboard page.

13. Defect Life Cycle (Bug Life Cycle)

The cycle a defect goes through from the time it is found until it is fixed and closed.

  1. New: Defect is identified and logged.
  2. Assigned: Project lead assigns the defect to a developer.
  3. Open: Developer starts analyzing the defect.
  4. Fixed: Developer makes necessary code changes and marks it as fixed.
  5. Pending Retest: Code is deployed for testing.
  6. Retest: Tester verifies the fix.
    • If Fixed: Status changes to Closed.
    • If Not Fixed: Status changes to Reopened (goes back to Assigned).

14. Applications of Software Testing in IT Companies

  • Banking & Fintech: Critical to prevent financial loss. Precision in calculations and high security are mandatory.
  • Healthcare: Testing ensures compliance (HIPAA) and reliability of life-saving medical devices or patient data software.
  • E-Commerce: Ensures the shopping cart works, payments process correctly, and the site can handle high traffic (Load testing) on days like Black Friday.
  • Telecommunications: Ensures billing accuracy and network connectivity software reliability.

15. Career Opportunities in DevOps and Software Testing

The industry demand for both roles is high due to the shift toward digital transformation.

Career Paths

  • DevOps Engineer: Manages the CI/CD pipeline, cloud infrastructure, and automation.
  • Site Reliability Engineer (SRE): Focuses on system availability, latency, performance, and capacity.
  • QA Engineer (Manual): Focuses on functional testing and user experience.
  • SDET (Software Development Engineer in Test): A developer who writes code to test the software (Automation testing).
  • Test Architect: Designs the overall testing infrastructure and strategy.

Required Skillsets

For DevOps:

  • Linux/Unix Fundamentals: Command line proficiency.
  • Scripting: Python, Bash, or Go.
  • Cloud: AWS, Azure, or Google Cloud.
  • Tools: Mastery of Git, Jenkins, Docker, Kubernetes.

For Software Testing:

  • Analytical Skills: Ability to break down complex logic.
  • Programming (for Automation): Java, Python, or C#.
  • Tools: Selenium, JIRA (Bug tracking), Postman (API testing).
  • SQL: Ability to query databases to verify test data.