Setup e2e_node to support testing on ARM64

* Enable dockerized build with --use-dockerized-build=true
* Build and create test artifacts for ARM64 with --target-build-arch=arm64
* Prepull multi-arch ready container image
* Download ARM64 binaries/packages if running on ARM64 machine
This commit is contained in:
Ike Ma
2023-03-30 17:01:38 +00:00
parent 6d09ab86c2
commit e21cf9a54e
7 changed files with 57 additions and 9 deletions

View File

@@ -107,7 +107,7 @@ func (c *ConformanceRemote) SetupTestPackage(tardir, systemSpecName string) erro
}
// Make sure we can find the newly built binaries
buildOutputDir, err := utils.GetK8sBuildOutputDir()
buildOutputDir, err := utils.GetK8sBuildOutputDir(builder.IsDockerizedBuild(), builder.GetTargetBuildArch())
if err != nil {
return fmt.Errorf("failed to locate kubernetes build output directory %v", err)
}

View File

@@ -48,7 +48,7 @@ func (n *NodeE2ERemote) SetupTestPackage(tardir, systemSpecName string) error {
}
// Make sure we can find the newly built binaries
buildOutputDir, err := utils.GetK8sBuildOutputDir()
buildOutputDir, err := utils.GetK8sBuildOutputDir(builder.IsDockerizedBuild(), builder.GetTargetBuildArch())
if err != nil {
return fmt.Errorf("failed to locate kubernetes build output directory: %w", err)
}
@@ -62,6 +62,7 @@ func (n *NodeE2ERemote) SetupTestPackage(tardir, systemSpecName string) error {
requiredBins := []string{"kubelet", "e2e_node.test", "ginkgo", "mounter", "gcp-credential-provider"}
for _, bin := range requiredBins {
source := filepath.Join(buildOutputDir, bin)
klog.V(2).Infof("Copying binaries from %s", source)
if _, err := os.Stat(source); err != nil {
return fmt.Errorf("failed to locate test binary %s: %w", bin, err)
}

View File

@@ -21,16 +21,16 @@ import (
"path/filepath"
"k8s.io/klog/v2"
"k8s.io/kubernetes/test/e2e_node/builder"
)
// utils.go contains functions used across test suites.
const (
cniVersion = "v1.2.0"
cniArch = "amd64"
cniDirectory = "cni/bin" // The CNI tarball places binaries under directory under "cni/bin".
cniConfDirectory = "cni/net.d"
cniURL = "https://storage.googleapis.com/k8s-artifacts-cni/release/" + cniVersion + "/" + "cni-plugins-linux-" + cniArch + "-" + cniVersion + ".tgz"
)
const cniConfig = `{
@@ -60,14 +60,25 @@ providers:
- "*.pkg.dev"
defaultCacheDuration: 1m`
func getCNIURL() string {
cniArch := "amd64"
if builder.IsTargetArchArm64() {
cniArch = "arm64"
}
cniURL := fmt.Sprintf("https://storage.googleapis.com/k8s-artifacts-cni/release/%s/cni-plugins-linux-%s-%s.tgz", cniVersion, cniArch, cniVersion)
return cniURL
}
// Install the cni plugin and add basic bridge configuration to the
// configuration directory.
func setupCNI(host, workspace string) error {
klog.V(2).Infof("Install CNI on %q", host)
cniPath := filepath.Join(workspace, cniDirectory)
klog.V(2).Infof("Install CNI on path %q", cniPath)
cmd := getSSHCommand(" ; ",
fmt.Sprintf("mkdir -p %s", cniPath),
fmt.Sprintf("curl -s -L %s | tar -xz -C %s", cniURL, cniPath),
fmt.Sprintf("curl -s -L %s | tar -xz -C %s", getCNIURL(), cniPath),
)
if output, err := SSH(host, "sh", "-c", cmd); err != nil {
return fmt.Errorf("failed to install cni plugin on %q: %v output: %q", host, err, output)