Skip to content

Commit 56d3ce6

Browse files
committed
apply the test case to oc tgm and dualfollower
Signed-off-by: Jack Ding <jackding@gmail.com>
1 parent f76ee4e commit 56d3ce6

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

test/conformance/serial/ptp.go

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,11 +1156,25 @@ var _ = Describe("["+strings.ToLower(DesiredMode.String())+"-serial]", Serial, f
11561156
if ptphelper.PtpEventEnabled() != 2 {
11571157
Skip("Skipping: test applies to event API v2 only")
11581158
}
1159-
if fullConfig.PtpModeDiscovered != testconfig.BoundaryClock &&
1160-
fullConfig.PtpModeDiscovered != testconfig.DualNICBoundaryClock &&
1161-
fullConfig.PtpModeDiscovered != testconfig.DualNICBoundaryClockHA {
1162-
Skip("Skipping: test applies to boundary clock configurations only")
1159+
1160+
// Determine expected clock class based on PTP mode
1161+
var expectedClockClass fbprotocol.ClockClass
1162+
switch fullConfig.PtpModeDiscovered {
1163+
case testconfig.OrdinaryClock:
1164+
// In 4.21+, OC correctly reports its local clock class (255/SlaveOnly).
1165+
// Before 4.21, OC was incorrectly detected as GM and reported upstream GM's class (6).
1166+
expectedClockClass = fbprotocol.ClockClass6
1167+
if ptphelper.IsPTPOperatorVersionAtLeast("4.21") {
1168+
expectedClockClass = fbprotocol.ClockClassSlaveOnly
1169+
}
1170+
case testconfig.BoundaryClock, testconfig.DualNICBoundaryClock, testconfig.DualNICBoundaryClockHA,
1171+
testconfig.TelcoGrandMasterClock:
1172+
expectedClockClass = fbprotocol.ClockClass6
1173+
default:
1174+
Skip(fmt.Sprintf("Skipping: test does not apply to %s mode", fullConfig.PtpModeDiscovered))
11631175
}
1176+
expectedClockClassStr := strconv.Itoa(int(expectedClockClass))
1177+
logrus.Infof("PtpModeDiscovered: %s, expected clockClass: %s", fullConfig.PtpModeDiscovered, expectedClockClassStr)
11641178

11651179
By("Deploying consumer app for event API v2")
11661180
nodeName := fullConfig.DiscoveredClockUnderTestPod.Spec.NodeName
@@ -1177,18 +1191,20 @@ var _ = Describe("["+strings.ToLower(DesiredMode.String())+"-serial]", Serial, f
11771191
})
11781192
time.Sleep(10 * time.Second)
11791193

1180-
By("Verifying initial clockClass is 6 via metrics")
1181-
checkClockClassState(fullConfig, strconv.Itoa(int(fbprotocol.ClockClass6)))
1194+
By(fmt.Sprintf("Verifying initial clockClass is %s via metrics", expectedClockClassStr))
1195+
checkClockClassState(fullConfig, expectedClockClassStr)
11821196

1183-
By("Verifying initial clockClass is 6 via PMC")
1197+
// PMC gm.ClockClass always reports the upstream GM's class (6),
1198+
// regardless of whether this node is BC or OC.
1199+
By("Verifying initial gm.ClockClass is 6 via PMC")
11841200
checkClockClassViaPMC(fullConfig, strconv.Itoa(int(fbprotocol.ClockClass6)))
11851201

1186-
By("Setting up event monitoring and verifying initial clockClass is 6 via Event API")
1202+
By(fmt.Sprintf("Setting up event monitoring and verifying initial clockClass is %s via Event API", expectedClockClassStr))
11871203
event.InitPubSub()
11881204
term, monErr := event.MonitorPodLogsRegex()
11891205
Expect(monErr).ToNot(HaveOccurred(), "could not start listening to events")
11901206
DeferCleanup(func() { stopMonitor(term) })
1191-
verifyClockClassViaEventAPI(int(fbprotocol.ClockClass6), 60*time.Second)
1207+
verifyClockClassViaEventAPI(int(expectedClockClass), 60*time.Second)
11921208

11931209
By("Killing cloud-event-proxy process in sidecar container")
11941210
_, _, killErr := pods.ExecCommand(
@@ -1226,14 +1242,14 @@ var _ = Describe("["+strings.ToLower(DesiredMode.String())+"-serial]", Serial, f
12261242
}, 2*time.Minute, 2*time.Second).Should(ContainSubstring("OK"),
12271243
"cloud-event-proxy health endpoint did not recover after restart")
12281244

1229-
By("Verifying clockClass remains 6 via metrics after cloud-event-proxy restart")
1230-
checkClockClassState(fullConfig, strconv.Itoa(int(fbprotocol.ClockClass6)))
1245+
By(fmt.Sprintf("Verifying clockClass remains %s via metrics after cloud-event-proxy restart", expectedClockClassStr))
1246+
checkClockClassState(fullConfig, expectedClockClassStr)
12311247

1232-
By("Verifying clockClass remains 6 via PMC after cloud-event-proxy restart")
1248+
By("Verifying gm.ClockClass remains 6 via PMC after cloud-event-proxy restart")
12331249
checkClockClassViaPMC(fullConfig, strconv.Itoa(int(fbprotocol.ClockClass6)))
12341250

1235-
By("Verifying clockClass is 6 via Event API after cloud-event-proxy restart")
1236-
verifyClockClassViaEventAPI(int(fbprotocol.ClockClass6), 90*time.Second)
1251+
By(fmt.Sprintf("Verifying clockClass is %s via Event API after cloud-event-proxy restart", expectedClockClassStr))
1252+
verifyClockClassViaEventAPI(int(expectedClockClass), 90*time.Second)
12371253
})
12381254

12391255
Context("Event API version validation", func() {

0 commit comments

Comments
 (0)