0
0
Testing Fundamentalstesting~10 mins

Performance test types (load, stress, spike, soak) in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates different performance test types on a web application to verify how it handles various user loads and stress conditions.

It checks if the application responds correctly under normal load, heavy stress, sudden spikes, and prolonged usage.

Test Code - unittest
Testing Fundamentals
import unittest
import time

class PerformanceTest(unittest.TestCase):
    def simulate_load(self, users):
        # Simulate normal load by sending requests equal to users
        return users <= 100  # Assume system supports up to 100 users normally

    def simulate_stress(self, users):
        # Simulate stress by sending requests beyond normal capacity
        return users <= 150  # System should handle up to 150 users under stress

    def simulate_spike(self, spike_users):
        # Simulate sudden spike in users
        return spike_users <= 200  # System can handle sudden spike up to 200 users

    def simulate_soak(self, duration_hours):
        # Simulate prolonged usage
        return duration_hours <= 5  # System stable for up to 5 hours

    def test_load(self):
        self.assertTrue(self.simulate_load(80))

    def test_stress(self):
        self.assertTrue(self.simulate_stress(140))

    def test_spike(self):
        self.assertTrue(self.simulate_spike(180))

    def test_soak(self):
        self.assertTrue(self.simulate_soak(4))

if __name__ == '__main__':
    unittest.main()
Execution Trace - 6 Steps
StepActionSystem StateAssertionResult
1Test startsTesting framework initialized, tests ready to run-PASS
2Run test_load: simulate 80 users normal loadSystem simulates 80 users sending requestsCheck if system supports 80 users under normal loadPASS
3Run test_stress: simulate 140 users stress loadSystem simulates 140 users sending requests beyond normal capacityCheck if system handles 140 users under stressPASS
4Run test_spike: simulate sudden spike of 180 usersSystem simulates sudden spike of 180 usersCheck if system handles sudden spike of 180 usersPASS
5Run test_soak: simulate 4 hours of continuous usageSystem simulates continuous usage for 4 hoursCheck if system remains stable for 4 hoursPASS
6All tests completedTest results collected-PASS
Failure Scenario
Failing Condition: System fails to handle user load beyond its capacity in any test
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test_load check in the performance tests?
ASystem stability over long hours
BSystem behavior under sudden user spikes
CSystem behavior under normal user load
DSystem failure under extreme stress
Key Result
Performance tests should cover different scenarios: normal load, stress beyond capacity, sudden spikes, and prolonged usage to ensure system reliability.