mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #30041 from Random-Liu/fix-node-name-in-node-e2e
Automatic merge from submit-queue Node E2E: Move the node name initialization to first function of SynchronizedBeforeEach Currently, we start e2e services in the first function of `SynchronizedBeforeEach` to make sure that we only start them once even we are running test in parallel test nodes. However, e2e services require `NodeName`, but we initialize `NodeName` in the second function. This PR moved the initialization logic into the first function, and shared the node name with all test nodes via the `SharedContext`.
This commit is contained in:
commit
d781225ac8
@ -102,6 +102,13 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||||||
if *buildServices {
|
if *buildServices {
|
||||||
buildGo()
|
buildGo()
|
||||||
}
|
}
|
||||||
|
if framework.TestContext.NodeName == "" {
|
||||||
|
hostname, err := os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatalf("Could not get node name: %v", err)
|
||||||
|
}
|
||||||
|
framework.TestContext.NodeName = hostname
|
||||||
|
}
|
||||||
|
|
||||||
// Pre-pull the images tests depend on so we can fail immediately if there is an image pull issue
|
// Pre-pull the images tests depend on so we can fail immediately if there is an image pull issue
|
||||||
// This helps with debugging test flakes since it is hard to tell when a test failure is due to image pulling.
|
// This helps with debugging test flakes since it is hard to tell when a test failure is due to image pulling.
|
||||||
@ -133,6 +140,8 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||||||
// Reference common test to make the import valid.
|
// Reference common test to make the import valid.
|
||||||
commontest.CurrentSuite = commontest.NodeE2E
|
commontest.CurrentSuite = commontest.NodeE2E
|
||||||
|
|
||||||
|
// Share the node name with the other test nodes.
|
||||||
|
shared.NodeName = framework.TestContext.NodeName
|
||||||
data, err := json.Marshal(shared)
|
data, err := json.Marshal(shared)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
@ -143,13 +152,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||||||
Expect(json.Unmarshal(data, shared)).To(Succeed())
|
Expect(json.Unmarshal(data, shared)).To(Succeed())
|
||||||
context = *shared
|
context = *shared
|
||||||
|
|
||||||
if framework.TestContext.NodeName == "" {
|
framework.TestContext.NodeName = shared.NodeName
|
||||||
hostname, err := os.Hostname()
|
|
||||||
if err != nil {
|
|
||||||
glog.Fatalf("Could not get node name: %v", err)
|
|
||||||
}
|
|
||||||
framework.TestContext.NodeName = hostname
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Tear down the kubelet on the node
|
// Tear down the kubelet on the node
|
||||||
|
@ -28,5 +28,6 @@ var startServices = flag.Bool("start-services", true, "If true, start local node
|
|||||||
var stopServices = flag.Bool("stop-services", true, "If true, stop local node services after running tests")
|
var stopServices = flag.Bool("stop-services", true, "If true, stop local node services after running tests")
|
||||||
|
|
||||||
type SharedContext struct {
|
type SharedContext struct {
|
||||||
|
NodeName string
|
||||||
PodConfigPath string
|
PodConfigPath string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user