Skip to content

Commit

Permalink
add node-env and instance-type flags to node-e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
upodroid committed Jul 21, 2023
1 parent 5f380d5 commit 1c99f95
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
31 changes: 24 additions & 7 deletions hack/make-rules/test-e2e-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
image_project=${IMAGE_PROJECT:-"cos-cloud"}
metadata=${INSTANCE_METADATA:-""}
gubernator=${GUBERNATOR:-"false"}
instance_type=${INSTANCE_TYPE:-""}
node_env="${NODE_ENV:-""}"
image_config_file=${IMAGE_CONFIG_FILE:-""}
image_config_dir=${IMAGE_CONFIG_DIR:-""}
use_dockerized_build=${USE_DOCKERIZED_BUILD:-""}
use_dockerized_build=${USE_DOCKERIZED_BUILD:-"false"}
target_build_arch=${TARGET_BUILD_ARCH:-""}
runtime_config=${RUNTIME_CONFIG:-""}
if [[ ${hosts} == "" && ${images} == "" && ${image_config_file} == "" ]]; then
Expand Down Expand Up @@ -159,11 +161,26 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
echo "Project: ${project}"
echo "Image Project: ${image_project}"
echo "Compute/Zone: ${zone}"
echo "Images: ${images}"
echo "Hosts: ${hosts}"
if [[ -n ${images} ]]; then
echo "Images: ${images}"
fi
if [[ -n ${hosts} ]]; then
echo "Hosts: ${hosts}"
fi
echo "Test Args: ${test_args}"
echo "Ginkgo Flags: ${ginkgoflags}"
echo "Instance Metadata: ${metadata}"
echo "Image Config File: ${image_config_file}"
if [[ -n ${metadata} ]]; then
echo "Instance Metadata: ${metadata}"
fi
if [[ -n ${node_env} ]]; then
echo "Node-env: \"${node_env}\""
fi
if [[ -n ${image_config_file} ]]; then
echo "Image Config File: ${image_config_dir}/${image_config_file}"
fi
if [[ -n ${instance_type} ]]; then
echo "Instance Type: ${instance_type}"
fi
echo "Kubelet Config File: ${kubelet_config_file}"

# Invoke the runner
Expand All @@ -176,8 +193,8 @@ if [ "${remote}" = true ] && [ "${remote_mode}" = gce ] ; then
--image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
--runtime-config="${runtime_config}" --preemptible-instances="${preemptible_instances}" \
--ssh-user="${ssh_user}" --ssh-key="${ssh_key}" --ssh-options="${ssh_options}" \
--image-config-dir="${image_config_dir}" \
--use-dockerized-build="${use_dockerized_build}" \
--image-config-dir="${image_config_dir}" --node-env="${node_env}" \
--use-dockerized-build="${use_dockerized_build}" --instance-type="${instance_type}" \
--target-build-arch="${target_build_arch}" \
--extra-envs="${extra_envs}" --kubelet-config-file="${kubelet_config_file}" --test-suite="${test_suite}" \
"${timeout_arg}" \
Expand Down
7 changes: 5 additions & 2 deletions test/e2e_node/remote/gce/gce_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var project = flag.String("project", "", "gce project the hosts live in (gce)")
var zone = flag.String("zone", "", "gce zone that the hosts live in (gce)")
var instanceMetadata = flag.String("instance-metadata", "", "key/value metadata for instances separated by '=' or '<', 'k=v' means the key is 'k' and the value is 'v'; 'k<p' means the key is 'k' and the value is extracted from the local path 'p', e.g. k1=v1,k2<p2 (gce)")
var imageProject = flag.String("image-project", "", "gce project the hosts live in (gce)")
var instanceType = flag.String("instance-type", "e2-medium", "GCP Machine type to use for test")
var preemptibleInstances = flag.Bool("preemptible-instances", false, "If true, gce instances will be configured to be preemptible (gce)")

func init() {
Expand All @@ -82,7 +83,7 @@ func init() {

const (
defaultGCEMachine = "n1-standard-1"
acceleratorTypeResourceFormat = "https://www.googleapis.com/compute/beta/projects/%s/zones/%s/acceleratorTypes/%s"
acceleratorTypeResourceFormat = "https://www.googleapis.com/compute/v1/projects/%s/zones/%s/acceleratorTypes/%s"
)

type GCERunner struct {
Expand Down Expand Up @@ -764,7 +765,9 @@ func (g *GCERunner) updateKernelArguments(instance *compute.Instance, image stri
}

func (g *GCERunner) machineType(machine string) string {
if machine == "" {
if machine == "" && *instanceType != "" {
machine = *instanceType
} else {
machine = defaultGCEMachine
}
return fmt.Sprintf("zones/%s/machineTypes/%s", *zone, machine)
Expand Down

0 comments on commit 1c99f95

Please sign in to comment.