test-e2e-node: support pure SSH mode

Right now, `run_remote.go` only supports GCE instances. But actually
running the tests is completely independent of GCE and could work just
as well on any SSH-accessible machine.

This patch adds a new `--mode` switch, which defaults to `gce` for
backwards compatibility, but can be set to `ssh`. In that mode, the GCE
API is not used at all, and we simply connect to the hosts given via
`--hosts`.

This is still better than `run_local.go` because the latter mixes build
environment with test environment, which doesn't fit well with
container-optimized operating systems.

This is part of an effort to setup the e2e node tests on Fedora CoreOS
(see https://github.com/coreos/fedora-coreos-tracker/issues/990).

Patch best viewed with whitespace ignored.
This commit is contained in:
Jonathan Lebon
2021-11-05 12:08:39 -04:00
parent e0723c1e64
commit 3ebd93cd02
3 changed files with 45 additions and 19 deletions

View File

@@ -49,6 +49,7 @@ import (
"sigs.k8s.io/yaml"
)
var mode = flag.String("mode", "gce", "Mode to operate in. One of gce|ssh. Defaults to gce")
var testArgs = flag.String("test_args", "", "Space-separated list of arguments to pass to Ginkgo test runner.")
var testSuite = flag.String("test-suite", "default", "Test suite the runner initializes with. Currently support default|cadvisor|conformance")
var instanceNamePrefix = flag.String("instance-name-prefix", "", "prefix for instance names")
@@ -223,22 +224,22 @@ func main() {
return
}
if *hosts == "" && *imageConfigFile == "" && *images == "" {
klog.Fatalf("Must specify one of --image-config-file, --hosts, --images.")
}
var err error
computeService, err = getComputeClient()
if err != nil {
klog.Fatalf("Unable to create gcloud compute service using defaults. Make sure you are authenticated. %v", err)
}
var gceImages *internalImageConfig
if gceImages, err = prepareGceImages(); err != nil {
klog.Fatalf("While preparing GCE images: %v", err)
}
if *instanceNamePrefix == "" {
*instanceNamePrefix = "tmp-node-e2e-" + uuid.New().String()[:8]
if *mode == "gce" {
if *hosts == "" && *imageConfigFile == "" && *images == "" {
klog.Fatalf("Must specify one of --image-config-file, --hosts, --images.")
}
var err error
computeService, err = getComputeClient()
if err != nil {
klog.Fatalf("Unable to create gcloud compute service using defaults. Make sure you are authenticated. %v", err)
}
if gceImages, err = prepareGceImages(); err != nil {
klog.Fatalf("While preparing GCE images: %v", err)
}
if *instanceNamePrefix == "" {
*instanceNamePrefix = "tmp-node-e2e-" + uuid.New().String()[:8]
}
}
// Setup coloring