Repository: openconfig/featureprofiles
Pull request #4026: initial commit for plt1.2
Author: login: rohit-rp
Created: 2025-03-17T05:51:53Z | Merged: 2025-03-21T08:09:53Z



Diff:
diff --git a/feature/platform/tests/parent_component_validation/README.md b/feature/platform/tests/parent_component_validation/README.md
new file mode 100644
index 00000000000..cc14f995c17
--- /dev/null
+++ b/feature/platform/tests/parent_component_validation/README.md
@@ -0,0 +1,39 @@
+# PLT-1.2: Parent component validation test
+
+## Summary
+
+Validate that the parent components of an entity is correct before and after reboot
+
+- Verify parent component of an interface is a Switch Chip
+- [TODO]: Add parent component verification for other hardware entities
+
+## Testbed type
+
+*   https://github.com/openconfig/featureprofiles/blob/main/topologies/atedut_2.testbed
+
+## Procedure
+
+* Connect ATE port-1 to DUT port-1, and ATE port-2 to DUT port-2
+
+### PLT-1.2.1 - Validate parent component of an interface:
+
+* Validate that the correct parent component "SwitchChip" is reported for DUT port1 and port2
+* Reboot the DUT and verify the DUT finished rebooting by checking the uptime
+* Re-validate that the correct parent component "SwitchChip" is reported for DUT port1 and port2
+
+## OpenConfig Path and RPC Coverage
+
+The below yaml defines the OC paths and RPC intended to be covered by this test.
+
+```yaml
+paths:
+  /components/component/state/parent:
+    platform_type: ["INTEGRATED_CIRCUIT"]
+rpcs:
+  gnmi:
+    gNMI.Get:
+```
+
+## Minimum DUT Platform Requirement
+
+- FFF
diff --git a/feature/platform/tests/parent_component_validation/metadata.textproto b/feature/platform/tests/parent_component_validation/metadata.textproto
new file mode 100644
index 00000000000..e259af60034
--- /dev/null
+++ b/feature/platform/tests/parent_component_validation/metadata.textproto
@@ -0,0 +1,7 @@
+# proto-file: github.com/openconfig/featureprofiles/proto/metadata.proto
+# proto-message: Metadata
+
+uuid:  "c90d0ef3-72ef-477a-8381-591930f1ecbe"
+plan_id:  "PLT-1.2"
+description:  "Parent component validation test"
+testbed:  TESTBED_DUT_ATE_2LINKS
diff --git a/feature/platform/tests/parent_component_validation/parent_component_validation.go b/feature/platform/tests/parent_component_validation/parent_component_validation.go
new file mode 100644
index 00000000000..15ac4534e07
--- /dev/null
+++ b/feature/platform/tests/parent_component_validation/parent_component_validation.go
@@ -0,0 +1,76 @@
+// Copyright 2025 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package parent_component_validation
+
+import (
+	"regexp"
+	"testing"
+
+	"github.com/openconfig/featureprofiles/internal/fptest"
+	"github.com/openconfig/ondatra"
+	"github.com/openconfig/ondatra/gnmi"
+)
+
+func TestMain(m *testing.M) {
+	fptest.RunTests(m)
+}
+
+func checkParentComponent(t *testing.T, dut *ondatra.DUTDevice, entity string) string {
+	parent := gnmi.Lookup(t, dut, gnmi.OC().Component(entity).Parent().State())
+	val, present := parent.Val()
+
+	if !present {
+		t.Errorf("Parent component NOT found for entify: %s", entity)
+	}
+	gotV := gnmi.Lookup(t, dut, gnmi.OC().Component(val).Name().State())
+	got, present := gotV.Val()
+
+	if present {
+		t.Logf("Found parent component %s for entity %s", got, entity)
+	}
+	return got
+}
+
+// TestInterfaceParentComponent tests that the parent component of any given interface is a Switch Chip.
+func TestInterfaceParentComponent(t *testing.T) {
+	dut := ondatra.DUT(t, "dut")
+	cases := []struct {
+		desc    string
+		port    string
+		pattern string
+	}{
+		{
+			desc:    "Port1",
+			port:    "port1",
+			pattern: "^(SwitchChip|NPU[0-9]|[0-9]/[0-9]/CPU[0-9]-NPU[0-9])$",
+		},
+		{
+			desc:    "Port2",
+			port:    "port2",
+			pattern: "^(SwitchChip|NPU[0-9]|[0-9]/[0-9]/CPU[0-9]-NPU[0-9])$",
+		},
+	}
+
+	for _, tc := range cases {
+		t.Run(tc.desc, func(t *testing.T) {
+			dp := dut.Port(t, tc.port)
+			parent := checkParentComponent(t, dut, dp.Name())
+			t.Logf("Interface %s parent is %s", dp.Name(), parent)
+			if ok, err := regexp.MatchString(tc.pattern, parent); !ok || err != nil {
+				t.Errorf("Interface %s parent did not match pattern %s: %v", dp.Name(), tc.pattern, err)
+			}
+		})
+	}
+}


Reviews:
user: login: AmrNJ
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-18T04:15:10Z
user: login: rohit-rp
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-18T04:53:30Z
user: login: AmrNJ
body: LGTM.
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-21T08:09:36Z
user: login: dplore
body: Hi, this overlaps / duplicates this test that also does parent component validation:

https://github.com/openconfig/featureprofiles/blob/8c4806b67aed4d00a3cf1c51ec7571564fe7602c/feature/platform/tests/telemetry_inventory_test/telemetry_inventory_test.go#L99 (gNMI-1.4: Telemetry: Inventory)

It would be okay to move the parent component validation into a separate test if you like.  

Also, I believe "gNMI-1.4: Telemetry: Inventory" implementation is better because it is more vendor neutral and utilizes more of the intended OC.  It properly checks for component type `INTEGRATED_CIRCUIT` instead of hardcoding vendor specific regex.  

Also this test was merged with static analysis failures.  Please fix them.  Now, every PR will have these failures until someone fixes them.  

state: COMMENTED
author_association: MEMBER
submitted_at: 2025-03-21T17:27:15Z

Review comments:
diff_hunk: @@ -0,0 +1,76 @@
+// Copyright 2025 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package parent_component_validation
+
+import (
+	"regexp"
+	"testing"
+
+	"github.com/openconfig/featureprofiles/internal/fptest"
+	"github.com/openconfig/ondatra"
+	"github.com/openconfig/ondatra/gnmi"
+)
+
+func TestMain(m *testing.M) {
+	fptest.RunTests(m)
+}
+
+func checkParentComponent(t *testing.T, dut *ondatra.DUTDevice, entity string) string {
+	parent := gnmi.Lookup(t, dut, gnmi.OC().Component(entity).Parent().State())
+	val, present := parent.Val()
+
+	if !present {
+		t.Errorf("Parent component NOT found for entify: %s", entity)
+	}
+	gotV := gnmi.Lookup(t, dut, gnmi.OC().Component(val).Name().State())
+	got, present := gotV.Val()
+
+	if present {
+		t.Logf("Found parent component %s for entity %s", got, entity)
+	}
+	return got
+}
+
+// TestInterfaceParentComponent tests that the parent component of any given interface is a Switch Chip.
+func TestInterfaceParentComponent(t *testing.T) {
+	dut := ondatra.DUT(t, "dut")
+	cases := []struct {
+		desc    string
+		port    string
+		pattern string
+	}{
+		{
+			desc:    "Port1",
+			port:    "port1",
+			pattern: "^(SwitchChip|NP|xe-0/0/0|0/0/CPU0)$",
+		},
+		{
+			desc:    "Port2",
+			port:    "port2",
+			pattern: "^(SwitchChip|NP|xe-0/0/0|0/0/CPU0)$",
path: feature/platform/tests/parent_component_validation/parent_component_validation.go
user: login: AmrNJ
body: Does the pattern match all vendor scenarios?
created_at: 2025-03-18T04:15:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,76 @@
+// Copyright 2025 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package parent_component_validation
+
+import (
+	"regexp"
+	"testing"
+
+	"github.com/openconfig/featureprofiles/internal/fptest"
+	"github.com/openconfig/ondatra"
+	"github.com/openconfig/ondatra/gnmi"
+)
+
+func TestMain(m *testing.M) {
+	fptest.RunTests(m)
+}
+
+func checkParentComponent(t *testing.T, dut *ondatra.DUTDevice, entity string) string {
+	parent := gnmi.Lookup(t, dut, gnmi.OC().Component(entity).Parent().State())
+	val, present := parent.Val()
+
+	if !present {
+		t.Errorf("Parent component NOT found for entify: %s", entity)
+	}
+	gotV := gnmi.Lookup(t, dut, gnmi.OC().Component(val).Name().State())
+	got, present := gotV.Val()
+
+	if present {
+		t.Logf("Found parent component %s for entity %s", got, entity)
+	}
+	return got
+}
+
+// TestInterfaceParentComponent tests that the parent component of any given interface is a Switch Chip.
+func TestInterfaceParentComponent(t *testing.T) {
+	dut := ondatra.DUT(t, "dut")
+	cases := []struct {
+		desc    string
+		port    string
+		pattern string
+	}{
+		{
+			desc:    "Port1",
+			port:    "port1",
+			pattern: "^(SwitchChip|NP|xe-0/0/0|0/0/CPU0)$",
+		},
+		{
+			desc:    "Port2",
+			port:    "port2",
+			pattern: "^(SwitchChip|NP|xe-0/0/0|0/0/CPU0)$",
path: feature/platform/tests/parent_component_validation/parent_component_validation.go
user: login: rohit-rp
body: No this is incorrect for Cisco, updated to the correct pattern
created_at: 2025-03-18T04:53:30Z
author_association: CONTRIBUTOR

PR comments:
user: login: coveralls
created_at: 2025-03-17T05:54:30Z
body: ## Pull Request Test Coverage Report for [Build 13915673977](https://coveralls.io/builds/72778510)


### Details

* **0** of **0**   changed or added relevant lines in **0** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **18.197%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/72778510/badge)](https://coveralls.io/builds/72778510) |
| :-- | --: |
| Change from base [Build 13906538638](https://coveralls.io/builds/72769169): |  0.0% |
| Covered Lines: | 2477 |
| Relevant Lines: | 13612 |

---
##### 💛  - [Coveralls](https://coveralls.io)

author_association: NONE
user: login: OpenConfigBot
created_at: 2025-03-17T18:29:03Z
body: ## Pull Request Functional Test Report for #4026 / 08d072e29a997dfefb3973b323a0fcc610681ff4


### Virtual Devices

| Device | Test | Test Documentation | Job | Raw Log |
| --- | --- | --- | --- | --- |
| Arista cEOS | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.ARISTA_cEOS.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> | [70dfa9db](https://console.cloud.google.com/cloud-build/builds;region=us-west1/70dfa9db-bbc9-407f-9c68-c3bd2078fb3b?project=6848975133) | [Log](https://storage.cloud.google.com/featureprofiles-ci-logs-arista/log-70dfa9db-bbc9-407f-9c68-c3bd2078fb3b.txt) |
| Cisco 8000E | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.CISCO_8000E.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> | [ab189c04](https://console.cloud.google.com/cloud-build/builds;region=us-west1/ab189c04-0e31-4deb-b452-9a5e70649d85?project=6848975133) | [Log](https://storage.cloud.google.com/featureprofiles-ci-logs-cisco/log-ab189c04-0e31-4deb-b452-9a5e70649d85.txt) |
| Cisco XRd | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.CISCO_XRd.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> | [b6a2308d](https://console.cloud.google.com/cloud-build/builds;region=us-west1/b6a2308d-bb6c-4f18-b62b-2235a87ea6bb?project=6848975133) | [Log](https://storage.cloud.google.com/featureprofiles-ci-logs-cisco/log-b6a2308d-bb6c-4f18-b62b-2235a87ea6bb.txt) |
| Juniper ncPTX | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.JUNIPER_ncPTX.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> | [f4bf02a5](https://console.cloud.google.com/cloud-build/builds;region=us-west1/f4bf02a5-9296-4709-9049-da4fb3617a03?project=6848975133) | [Log](https://storage.cloud.google.com/featureprofiles-ci-logs-juniper/log-f4bf02a5-9296-4709-9049-da4fb3617a03.txt) |
| Nokia SR Linux | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.NOKIA_SR_Linux.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> | [506be8e8](https://console.cloud.google.com/cloud-build/builds;region=us-west1/506be8e8-9673-420d-8a59-22927911e049?project=6848975133) | [Log](https://storage.cloud.google.com/featureprofiles-ci-logs-nokia/log-506be8e8-9673-420d-8a59-22927911e049.txt) |
| Openconfig Lemming | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.OPENCONFIG_Lemming.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> | [52a674a1](https://console.cloud.google.com/cloud-build/builds;region=us-west1/52a674a1-0b53-4fa5-903e-70439fc33e38?project=6848975133) | [Log](https://storage.cloud.google.com/featureprofiles-ci-logs-openconfig/log-52a674a1-0b53-4fa5-903e-70439fc33e38.txt) |

### Hardware Devices

| Device | Test | Test Documentation | Raw Log |
| --- | --- | --- | --- |
| Arista 7808 | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.ARISTA_7808.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> |  |
| Cisco 8808 | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.CISCO_8808.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> |  |
| Juniper PTX10008 | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.JUNIPER_PTX10008.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> |  |
| Nokia 7250 IXR-10e | [![status](https://storage.googleapis.com/featureprofiles-ci/badges/4026/08d072e29a997dfefb3973b323a0fcc610681ff4/ZmVhdHVyZS9wbGF0Zm9ybS90ZXN0cy9wYXJlbnRfY29tcG9uZW50X3ZhbGlkYXRpb24.NOKIA_7250_IXR-10e.svg)](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation)<br /> | [PLT-1.2: Parent component validation test](https://github.com/openconfig/featureprofiles/blob/08d072e29a997dfefb3973b323a0fcc610681ff4/feature/platform/tests/parent_component_validation/README.md)<br /> |  |

[Help](https://gist.github.com/OpenConfigBot/7dadd09b7c3133c9d8bc0d08fcb19b46)
author_association: NONE