|
4 | 4 | from pathlib import Path |
5 | 5 | from typing import Callable, Optional |
6 | 6 |
|
| 7 | +import pexpect |
7 | 8 | from scenarios_test import ScenariosTest |
8 | 9 | from test_base import TestBase |
9 | 10 |
|
@@ -49,7 +50,9 @@ def run_test(self): |
49 | 50 | self.setup_namespaces() |
50 | 51 | self.setup_service_accounts() |
51 | 52 | self.setup_network() |
| 53 | + self.admin_checks_logs() |
52 | 54 | self.authenticate_and_become_bob() |
| 55 | + self.bob_checks_logs() |
53 | 56 | self.bob_runs_scenario_tests() |
54 | 57 | finally: |
55 | 58 | self.return_to_initial_context() |
@@ -176,6 +179,56 @@ def bob_runs_scenario_tests(self): |
176 | 179 | super().run_test() |
177 | 180 | assert self.this_is_the_current_context(self.bob_context) |
178 | 181 |
|
| 182 | + def bob_checks_logs(self): |
| 183 | + assert self.this_is_the_current_context(self.bob_context) |
| 184 | + self.log.info("Bob will check the logs") |
| 185 | + bitcoin_version_slug = "Bitcoin Core version v27.0.0" |
| 186 | + self.sut = pexpect.spawn("warnet logs", maxread=4096 * 10) |
| 187 | + self.sut.expect("Please choose a pod", timeout=10) |
| 188 | + self.sut.sendline("") |
| 189 | + self.sut.expect(bitcoin_version_slug, timeout=10) |
| 190 | + self.sut.close() |
| 191 | + self.sut = pexpect.spawn(f"warnet logs --namespace {self.red_namespace}", maxread=4096 * 10) |
| 192 | + self.sut.expect("Please choose a pod", timeout=10) |
| 193 | + self.sut.sendline("") |
| 194 | + self.sut.expect(bitcoin_version_slug, timeout=10) |
| 195 | + self.sut.close() |
| 196 | + self.sut = pexpect.spawn("warnet logs tank-0008", maxread=4096 * 10) |
| 197 | + self.sut.expect(bitcoin_version_slug, timeout=10) |
| 198 | + self.sut.close() |
| 199 | + self.sut = pexpect.spawn( |
| 200 | + f"warnet logs tank-0008 --namespace {self.red_namespace}", maxread=4096 * 10 |
| 201 | + ) |
| 202 | + self.sut.expect(bitcoin_version_slug, timeout=10) |
| 203 | + self.sut.close() |
| 204 | + self.log.info("Bob has checked the logs") |
| 205 | + assert self.this_is_the_current_context(self.bob_context) |
| 206 | + |
| 207 | + def admin_checks_logs(self): |
| 208 | + assert self.this_is_the_current_context(self.initial_context) |
| 209 | + self.log.info("The admin will check the logs") |
| 210 | + bitcoin_version_slug = "Bitcoin Core version v27.0.0" |
| 211 | + self.sut = pexpect.spawn("warnet logs", maxread=4096 * 10) |
| 212 | + self.sut.expect("Please choose a pod", timeout=10) |
| 213 | + self.sut.sendline("") |
| 214 | + self.sut.expect(bitcoin_version_slug, timeout=10) |
| 215 | + self.sut.close() |
| 216 | + self.sut = pexpect.spawn(f"warnet logs --namespace {self.red_namespace}", maxread=4096 * 10) |
| 217 | + self.sut.expect("Please choose a pod", timeout=10) |
| 218 | + self.sut.sendline("") |
| 219 | + self.sut.expect(bitcoin_version_slug, timeout=10) |
| 220 | + self.sut.close() |
| 221 | + self.sut = pexpect.spawn("warnet logs tank-0008", maxread=4096 * 10) |
| 222 | + self.sut.expect("The pod 'tank-0008' is found in these namespaces", timeout=10) |
| 223 | + self.sut.close() |
| 224 | + self.sut = pexpect.spawn( |
| 225 | + f"warnet logs tank-0008 --namespace {self.red_namespace}", maxread=4096 * 10 |
| 226 | + ) |
| 227 | + self.sut.expect(bitcoin_version_slug, timeout=10) |
| 228 | + self.sut.close() |
| 229 | + self.log.info("The admin has checked the logs") |
| 230 | + assert self.this_is_the_current_context(self.initial_context) |
| 231 | + |
179 | 232 |
|
180 | 233 | def remove_user(kubeconfig_data: dict, username: str) -> dict: |
181 | 234 | kubeconfig_data["users"] = [ |
|
0 commit comments