Skip to content

Commit

Permalink
apply siblings flag for wwan reconnection test
Browse files Browse the repository at this point in the history
apply siblings flag for wwan reconnection test
  • Loading branch information
stanley31huang committed Oct 8, 2024
1 parent 0f1a673 commit cf8e538
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 38 deletions.
31 changes: 12 additions & 19 deletions providers/base/bin/wwan_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,6 @@ def register_arguments(self):
action="store_true",
help="Use mmcli for all calls rather than dbus",
)
parser.add_argument(
"--iteration",
type=int,
help="The iteration to print out wwan resource",
)
return parser.parse_args(sys.argv[2:])

def invoked(self):
Expand All @@ -477,20 +472,18 @@ def invoked(self):
else:
mm = MMDbus()

for idx in range(1, args.iteration + 1):
for m in mm.get_modem_ids():
print("iteration: {}".format(idx))
print("mm_id: {}".format(m))
print("hw_id: {}".format(mm.get_equipment_id(m)))
print("manufacturer: {}".format(mm.get_manufacturer(m)))
print("model: {}".format(mm.get_model_name(m)))
print(
"firmware_revision: {}".format(mm.get_firmware_revision(m))
)
print(
"hardware_revision: {}".format(mm.get_hardware_revision(m))
)
print()
for m in mm.get_modem_ids():
print("mm_id: {}".format(m))
print("hw_id: {}".format(mm.get_equipment_id(m)))
print("manufacturer: {}".format(mm.get_manufacturer(m)))
print("model: {}".format(mm.get_model_name(m)))
print(
"firmware_revision: {}".format(mm.get_firmware_revision(m))
)
print(
"hardware_revision: {}".format(mm.get_hardware_revision(m))
)
print()


class SimPresent:
Expand Down
20 changes: 7 additions & 13 deletions providers/base/tests/test_wwan_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,7 @@ def test_invoked_with_mmcli(self, mock_mmcli):
mmcli_instance.get_modem_ids.return_value = ["test"]
mock_mmcli.return_value = mmcli_instance

sys.argv = [
"wwan_tests.py",
"resources",
"--use-cli",
"--iteration",
"1",
]
sys.argv = ["wwan_tests.py", "resources", "--use-cli"]

with redirect_stdout(StringIO()):
wwan_tests.Resources().invoked()
Expand All @@ -111,19 +105,19 @@ def test_invoked_with_mmdbus(self, mock_mmdbus):
mmdbus_instance.get_modem_ids.return_value = ["test"]
mock_mmdbus.return_value = mmdbus_instance

sys.argv = ["wwan_tests.py", "resources", "--iteration", "2"]
sys.argv = ["wwan_tests.py", "resources"]

with redirect_stdout(StringIO()):
wwan_tests.Resources().invoked()
self.assertEqual(mock_mmdbus.call_count, 1)
self.assertEqual(mmdbus_instance.get_equipment_id.call_count, 2)
self.assertEqual(mmdbus_instance.get_manufacturer.call_count, 2)
self.assertEqual(mmdbus_instance.get_model_name.call_count, 2)
self.assertEqual(mmdbus_instance.get_equipment_id.call_count, 1)
self.assertEqual(mmdbus_instance.get_manufacturer.call_count, 1)
self.assertEqual(mmdbus_instance.get_model_name.call_count, 1)
self.assertEqual(
mmdbus_instance.get_firmware_revision.call_count, 2
mmdbus_instance.get_firmware_revision.call_count, 1
)
self.assertEqual(
mmdbus_instance.get_hardware_revision.call_count, 2
mmdbus_instance.get_hardware_revision.call_count, 1
)


Expand Down
13 changes: 8 additions & 5 deletions providers/base/units/wwan/jobs.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ requires:
unit: template
template-resource: wwan_resource
template-unit: job
id: wwan/gsm-connection-{manufacturer}-{model}-{hw_id}-cycle{iteration}-auto
id: wwan/gsm-connection-{manufacturer}-{model}-{hw_id}-auto
template-id: wwan/gsm-connection-manufacturer-model-hw_id-auto
_summary: Verify a GSM broadband modem can create a data connection - iteration #{iteration}
_summary: Verify a GSM broadband modem can create a data connection
_template-summary: Verify a GSM broadband modem can create a data connection multiple times
_purpose:
Any modems discovered by the resource job that list GSM support
Expand All @@ -57,13 +57,18 @@ requires:
manifest.has_wwan_module == 'True'
manifest.has_sim_card == 'True'
snap.name == 'modem-manager' or package.name == 'modemmanager'
_siblings:
[{{
"id": "wwan/gsm-reconnection-{manufacturer}-{model}-{hw_id}-auto",
"_summary": "Verify a GSM broadband modem can recreate a data connection",
"depends": "wwan/gsm-connection-{manufacturer}-{model}-{hw_id}-auto"
}}]

unit: template
template-resource: wwan_resource
template-unit: job
id: wwan/check-sim-present-{manufacturer}-{model}-{hw_id}-auto
template-id: wwan/check-sim-present-manufacturer-model-hw_id-auto
template-filter: wwan_resource.iteration == '1'
_summary: Check if a SIM card is present in a slot connected to the modem
_description:
Check if a SIM card is present in a slot connected to the modem
Expand All @@ -85,7 +90,6 @@ template-resource: wwan_resource
template-unit: job
id: wwan/verify-sim-info-{manufacturer}-{model}-{hw_id}
template-id: wwan/verify-sim-info-manufacturer-model-hw_id
template-filter: wwan_resource.iteration == '1'
depends: wwan/check-sim-present-{manufacturer}-{model}-{hw_id}-auto
_summary: Verify that the information retrieved from a SIM card is valid
_purpose:
Expand Down Expand Up @@ -113,7 +117,6 @@ template-resource: wwan_resource
template-unit: job
id: wwan/3gpp-scan-{manufacturer}-{model}-{hw_id}-auto
template-id: wwan/3gpp-scan-manufacturer-model-hw_id-auto
template-filter: wwan_resource.iteration == '1'
_summary: Scan for available 3GPP networks with the modem
_template-summary: Scan for available 3GPP networks with the {model} modem
_description:
Expand Down
2 changes: 1 addition & 1 deletion providers/base/units/wwan/resource.pxu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ category_id: wwan
plugin: resource
_summary: Gather device info about WWAN modems
_description: Gather device info about WWAN modems
command: wwan_tests.py resources --iteration "${WWAN_CONNECTION_TEST_COUNT:-2}"
command: wwan_tests.py resources
user: root
estimated_duration: 3s
flags: preserve-locale

0 comments on commit cf8e538

Please sign in to comment.