Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test/packet instructions for running CI tests on dedicated instances #16423

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 29 additions & 26 deletions test/packet/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# Instructions to run CI tests in your own packet-net instances

# 1 - download terraform https://www.terraform.io/downloads.html
# 2 - get your API key by clicking in your user profile (top right corner)
# and pick "API Keys" https://app.packet.net/login
# 3 - Create an API Key with read/write permissions and give a description,
# something like "CI private testing"
# 4 - store the private token as you will need it in the next steps
# 5 - go to the packet.net and pick or create a project ID
# 6 - terraform init .
# 7 - terraform apply
# 8 - After the VM is up and running you can check its IP with `terraform show`
# 9 - SSH in to the public IP with `ssh -i <ssh-key-path> root@<publicIP>`
# 10 - Checkout to the branch that you want to test `git checkout <my-faulty-branch>`
# 11 - Run `screen` which will create a new terminal, this is helpful as you can leave your terminal while
# tests are running and come back again afterwards.
# 12 - Enter the `test` directory with `cd test`
# 13 - Run the ginkgo command to initialize the tests, for example:
# `K8S_VERSION=1.14 ginkgo --focus="K8s" -v -- --cilium.showCommands --cilium.holdEnvironment=true`
# 14 - Once tests are running and if you are running `screen`, you can leave the terminal
# by typing `CTRL+a+d`, to resume again type `screen -r`
#
export TF_VAR_private_key_path="<SSH KEY PATH>"
export TF_VAR_packet_token="<TOKEN>"
export TF_VAR_packet_project_id="<PROJECT ID>"
# the location for europeans is better to pick Amsterdam (ams1) or Toronto (yyz1)
export TF_VAR_packet_location="ams1"
export TF_VAR_packet_plan="c1.small.x86"
1) Download terraform https://www.terraform.io/downloads.html
2) Get your API key by clicking in your user profile (top right corner) and
pick "API Keys" https://app.packet.net/login
3) Create an API Key with read/write permissions and give a description,
something like "CI private testing"
4) Store the private token as you will need it in the next steps
5) Go to the packet.net and pick or create a project ID
6) Generate your own SSH keys via `ssk-keygen`
7) Set the following env vars:
```
export TF_VAR_public_key_path="<SSH PUB KEY PATH>"
export TF_VAR_private_key_path="<SSH PRIV KEY PATH>"
export TF_VAR_metal_token="<TOKEN>"
export TF_VAR_metal_project_id="<PROJECT ID>"
# For europeans it's better to pick Amsterdam (ams1) or Toronto (yyz1)
export TF_VAR_metal_location="ams1"
export TF_VAR_metal_plan="c1.small.x86"
```
8) `terraform init`
9) `terraform apply`
10) After the VM is up and running you can check its IP with `terraform show`
11) SSH in to the public IP with `ssh -i <ssh-key-path> root@<publicIP>`
12) Checkout to the branch that you want to test `git checkout <my-faulty-branch>`
13) Run `screen` which will create a new terminal, this is helpful as you can leave your terminal while tests are running and come back again afterwards.
14) Enter the `test` directory with `cd test`
15) Run the ginkgo command to initialize the tests, for example:
`K8S_VERSION=1.14 ginkgo --focus="K8s" -v -- --cilium.showCommands --cilium.holdEnvironment=true`
16) Once tests are running and if you are running `screen`, you can leave the terminal
by typing `CTRL+a+d`, to resume again type `screen -r`
70 changes: 39 additions & 31 deletions test/packet/main.tf
Original file line number Diff line number Diff line change
@@ -1,56 +1,64 @@
variable "private_key_path" {
terraform {
required_providers {
metal = {
source = "equinix/metal"
}
}
}

variable "packet_token" {
}
variable "public_key_path" {}
variable "private_key_path" {}

variable "packet_project_id" {
}

variable "packet_plan" {
default="baremetal_0"
}
variable "metal_token" {}
variable "metal_project_id" {}
variable "metal_plan" {}

variable "packet_location" {
variable "metal_location" {
default="sjc1"
}

variable "nodes" {
default = 1
}

provider "packet" {
auth_token = var.packet_token
provider "metal" {
auth_token = var.metal_token
}

resource "metal_ssh_key" "key1" {
name = "key1"
public_key = file(var.public_key_path)
}

# Create a device and add it to tf_project_1
resource "packet_device" "test" {
resource "metal_device" "test" {
count = var.nodes
hostname = "test-${count.index}"
plan = var.packet_plan
facilities = [ var.packet_location ]
operating_system = "ubuntu_18_04"
plan = var.metal_plan
facilities = [ var.metal_location ]
operating_system = "ubuntu_20_04"
billing_cycle = "hourly"
project_id = var.packet_project_id
project_id = var.metal_project_id
depends_on = [ metal_ssh_key.key1 ]

connection {
type = "ssh"
host = packet_device.test[count.index].access_public_ipv4
user = "root"
private_key = file(var.private_key_path)
agent = false
}
connection {
type = "ssh"
host = metal_device.test[count.index].access_public_ipv4
user = "root"
private_key = file(var.private_key_path)
agent = false
}

provisioner "file" {
source="scripts"
destination="/provision"
source="scripts"
destination="/provision"
}

provisioner "remote-exec" {
inline = [
provisioner "remote-exec" {
inline = [
"sudo chmod 755 /provision/*.sh",
"sudo /provision/install.sh",
"sudo /provision/install.sh",
"go get -u github.com/cilium/cilium || true"
]
}
]
}
}
7 changes: 3 additions & 4 deletions test/packet/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ set -e
export DEBIAN_FRONTEND=noninteractive

GOLANG_VERSION="1.16.4"
VAGRANT_VERSION="2.2.4"
VAGRANT_VERSION="2.2.16"
PACKER_VERSION="1.3.5"
VIRTUALBOX_VERSION="6.0"

#repositories

Expand All @@ -26,11 +25,11 @@ sudo add-apt-repository \
sudo --preserve-env=DEBIAN_FRONTEND apt-get update
sudo --preserve-env=DEBIAN_FRONTEND apt-get install -y \
curl jq apt-transport-https htop bmon zip \
nfs-common nfs-kernel-server \
linux-tools-common linux-tools-generic \
ca-certificates software-properties-common \
git openjdk-8-jdk gcc make perl unzip awscli \
linux-headers-`uname -r` \
virtualbox-${VIRTUALBOX_VERSION} docker-ce
linux-headers-`uname -r` virtualbox docker-ce

cd /tmp/
wget https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_x86_64.deb
Expand Down