Skip to content

Commit

Permalink
enable test handler for containerd runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
upodroid committed Nov 23, 2023
1 parent 419b93b commit 8f749a5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ gcs-publish-ci: gsutil version-dist-ci
@echo "== Uploading kops =="
gsutil -h "Cache-Control:private, max-age=0, no-transform" -m cp -n -r ${UPLOAD}/kops/* ${GCS_LOCATION}
echo "VERSION: ${VERSION}"
echo "${GCS_URL}/${VERSION}" > ${UPLOAD}/${LATEST_FILE}
echo "${GCS_URL}${VERSION}" > ${UPLOAD}/${LATEST_FILE}
gsutil -h "Cache-Control:private, max-age=0, no-transform" cp ${UPLOAD}/${LATEST_FILE} ${GCS_LOCATION}

.PHONY: gen-cli-docs
Expand Down
10 changes: 0 additions & 10 deletions tests/e2e/kubetest2-kops/deployer/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strings"
"time"

"k8s.io/klog/v2"
"k8s.io/kops/tests/e2e/kubetest2-kops/gce"
"k8s.io/kops/tests/e2e/pkg/kops"
"k8s.io/kops/tests/e2e/pkg/target"
"k8s.io/kops/tests/e2e/pkg/util"
"sigs.k8s.io/kubetest2/pkg/boskos"
Expand All @@ -51,14 +49,6 @@ func (d *deployer) initialize() error {
return fmt.Errorf("init failed to check up flags: %v", err)
}
}
if d.KopsVersionMarker != "" {
d.KopsBinaryPath = path.Join(d.commonOptions.RunDir(), "kops")
baseURL, err := kops.DownloadKops(d.KopsVersionMarker, d.KopsBinaryPath)
if err != nil {
return fmt.Errorf("init failed to download kops from url: %v", err)
}
d.KopsBaseURL = baseURL
}

switch d.CloudProvider {
case "aws":
Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/kubetest2-kops/deployer/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
osexec "os/exec"
"path"
"strings"
"time"

Expand All @@ -41,6 +42,17 @@ func (d *deployer) Up() error {
return err
}

// kops is fetched when --up is called instead of init to support a scenario where k/k is being built
// and a kops build is not ready yet
if d.KopsVersionMarker != "" {
d.KopsBinaryPath = path.Join(d.commonOptions.RunDir(), "kops")
baseURL, err := kops.DownloadKops(d.KopsVersionMarker, d.KopsBinaryPath)
if err != nil {
return fmt.Errorf("init failed to download kops from url: %v", err)
}
d.KopsBaseURL = baseURL
}

if d.terraform == nil {
klog.Info("Cleaning up any leaked resources from previous cluster")
// Intentionally ignore errors:
Expand Down Expand Up @@ -118,6 +130,7 @@ func (d *deployer) createCluster(zones []string, adminAccess string, yes bool) e
"--kubernetes-version", d.KubernetesVersion,
"--ssh-public-key", d.SSHPublicKeyPath,
"--set", "cluster.spec.nodePortAccess=0.0.0.0/0",
"--set", `spec.containerd.configAdditions="plugins.""io.containerd.grpc.v1.cri"".containerd.runtimes.test-handler.runtime_type=""io.containerd.runc.v2"""`,
}
if yes {
args = append(args, "--yes")
Expand Down
23 changes: 23 additions & 0 deletions tests/e2e/pkg/kops/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"k8s.io/klog/v2"
api "k8s.io/kops/pkg/apis/kops/v1alpha2"
"k8s.io/kops/pkg/cloudinstances"
"sigs.k8s.io/kubetest2/pkg/exec"
)

Expand Down Expand Up @@ -61,6 +62,28 @@ func GetCluster(kopsBinary, clusterName string, env []string) (*api.Cluster, err
return cluster, nil
}

// GetCluster will retrieve the specified Cluster from the state store.
func GetInstances(kopsBinary, clusterName string, env []string) ([]*cloudinstances.CloudInstance, error) {
args := []string{
kopsBinary, "get", "instances", "--name", clusterName, "-ojson",
}
c := exec.Command(args[0], args[1:]...)
c.SetEnv(env...)
var stdout bytes.Buffer
c.SetStdout(&stdout)
var stderr bytes.Buffer
c.SetStderr(&stderr)
if err := c.Run(); err != nil {
klog.Warningf("failed to run %s; stderr=%s", strings.Join(args, " "), stderr.String())
return nil, fmt.Errorf("error querying instances from %s: %w", strings.Join(args, " "), err)
}
var instances []*cloudinstances.CloudInstance
if err := json.Unmarshal(stdout.Bytes(), &instances); err != nil {
return nil, fmt.Errorf("error parsing instance groups json: %w", err)
}
return instances, nil
}

// GetInstanceGroups will retrieve the instance groups for the specified Cluster from the state store.
func GetInstanceGroups(kopsBinary, clusterName string, env []string) ([]*api.InstanceGroup, error) {
args := []string{
Expand Down

0 comments on commit 8f749a5

Please sign in to comment.