Skip to content

Commit 0981f00

Browse files
authored
Add E2E Split Server to Drone, support parrallel testing in Drone (#9940)
* Fix SE old test name * E2E: support multiple VMs at once in CI with time prefix * Add local binary support to split server test, add to drone CI * Cleanup old VMs in drone Signed-off-by: Derek Nola <[email protected]>
1 parent 5c94ce2 commit 0981f00

File tree

21 files changed

+165
-41
lines changed

21 files changed

+165
-41
lines changed

.drone.yml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -617,33 +617,24 @@ steps:
617617
- mkdir -p dist/artifacts
618618
- cp /tmp/artifacts/* dist/artifacts/
619619
- docker stop registry && docker rm registry
620-
# Cleanup VMs running, happens if a previous test panics
621-
# Cleanup inactive domains, happens if previous test is canceled
622-
- |
623-
VMS=$(virsh list --name | grep '_server-\|_agent-' || true)
624-
if [ -n "$VMS" ]; then
625-
for vm in $VMS
626-
do
627-
virsh destroy $vm
628-
virsh undefine $vm --remove-all-storage
629-
done
630-
fi
631-
VMS=$(virsh list --name --inactive | grep '_server-\|_agent-' || true)
632-
if [ -n "$VMS" ]; then
633-
for vm in $VMS
634-
do
635-
virsh undefine $vm
636-
done
637-
fi
620+
# Cleanup VMs that are older than 2h. Happens if a previous test panics or is canceled
621+
- tests/e2e/scripts/cleanup_vms.sh
638622
- docker run -d -p 5000:5000 -e REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io --name registry registry:2
639-
- cd tests/e2e/validatecluster
640-
- vagrant destroy -f
641-
- go test -v -timeout=45m ./validatecluster_test.go -ci -local
642-
- cp ./coverage.out /tmp/artifacts/validate-coverage.out
643-
- cd ../secretsencryption
644-
- vagrant destroy -f
645-
- go test -v -timeout=30m ./secretsencryption_test.go -ci -local
646-
- cp ./coverage.out /tmp/artifacts/se-coverage.out
623+
- |
624+
cd tests/e2e/validatecluster
625+
vagrant destroy -f
626+
go test -v -timeout=45m ./validatecluster_test.go -ci -local
627+
cp ./coverage.out /tmp/artifacts/validate-coverage.out
628+
- |
629+
cd ../secretsencryption
630+
vagrant destroy -f
631+
go test -v -timeout=30m ./secretsencryption_test.go -ci -local
632+
cp ./coverage.out /tmp/artifacts/se-coverage.out
633+
- |
634+
cd ../splitserver
635+
vagrant destroy -f
636+
go test -v -timeout=30m ./splitserver_test.go -ci -local
637+
cp ./coverage.out /tmp/artifacts/split-coverage.out
647638
- |
648639
if [ "$DRONE_BUILD_EVENT" = "pull_request" ]; then
649640
cd ../upgradecluster
@@ -669,6 +660,7 @@ steps:
669660
files:
670661
- /tmp/artifacts/validate-coverage.out
671662
- /tmp/artifacts/se-coverage.out
663+
- /tmp/artifacts/split-coverage.out
672664
- /tmp/artifacts/upgrade-coverage.out
673665
flags:
674666
- e2etests

tests/e2e/dualstack/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ Vagrant.configure("2") do |config|
9090
config.vm.provider "libvirt" do |v|
9191
v.cpus = NODE_CPUS
9292
v.memory = NODE_MEMORY
93+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
94+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
9395
end
9496

9597
if NODE_ROLES.kind_of?(String)

tests/e2e/embeddedmirror/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Vagrant.configure("2") do |config|
9797
config.vm.provider "libvirt" do |v|
9898
v.cpus = NODE_CPUS
9999
v.memory = NODE_MEMORY
100+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
101+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
100102
end
101103
config.vm.provider "virtualbox" do |v|
102104
v.cpus = NODE_CPUS

tests/e2e/externalip/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Vagrant.configure("2") do |config|
6565
config.vm.provider "libvirt" do |v|
6666
v.cpus = NODE_CPUS
6767
v.memory = NODE_MEMORY
68+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
69+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
6870
end
6971

7072
if NODE_ROLES.kind_of?(String)

tests/e2e/privateregistry/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Vagrant.configure("2") do |config|
103103
config.vm.provider "libvirt" do |v|
104104
v.cpus = NODE_CPUS
105105
v.memory = NODE_MEMORY
106+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
107+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
106108
end
107109
config.vm.provider "virtualbox" do |v|
108110
v.cpus = NODE_CPUS

tests/e2e/rootless/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Vagrant.configure("2") do |config|
4545
config.vm.provider "libvirt" do |v|
4646
v.cpus = NODE_CPUS
4747
v.memory = NODE_MEMORY
48+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
49+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
4850
end
4951
config.vm.provider "virtualbox" do |v|
5052
v.cpus = NODE_CPUS

tests/e2e/rotateca/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Vagrant.configure("2") do |config|
6565
config.vm.provider "libvirt" do |v|
6666
v.cpus = NODE_CPUS
6767
v.memory = NODE_MEMORY
68+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
69+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
6870
end
6971
config.vm.provider "virtualbox" do |v|
7072
v.cpus = NODE_CPUS

tests/e2e/s3/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Vagrant.configure("2") do |config|
6969
config.vm.provider "libvirt" do |v|
7070
v.cpus = NODE_CPUS
7171
v.memory = NODE_MEMORY
72+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
73+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
7274
end
7375
config.vm.provider "virtualbox" do |v|
7476
v.cpus = NODE_CPUS

tests/e2e/scripts/cleanup_vms.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Clean up any VMS that are older than 2 hours.
4+
#
5+
# We embed the time in the VM name, so we can easily filter them out.
6+
7+
# Get the current time in seconds since the epoch
8+
current_time=$(date +%s)
9+
10+
# Get the list of VMs
11+
vms=$(virsh list --name --all)
12+
time_regex="_([0-9]+)_(server|agent)"
13+
# Cleanup running VMs, happens if a previous test panics
14+
for vm in $vms; do
15+
if [[ $vm =~ $time_regex ]]; then
16+
vm_time="${BASH_REMATCH[1]}"
17+
age=$((current_time - vm_time))
18+
if [ $age -gt 7200 ]; then
19+
virsh destroy $vm
20+
virsh undefine $vm --remove-all-storage
21+
fi
22+
fi
23+
done
24+
25+
# Cleanup inactive domains, happens if previous test is canceled
26+
vms=$(virsh list --name --inactive)
27+
for vm in $vms; do
28+
if [[ $vm =~ $time_regex ]]; then
29+
vm_time="${BASH_REMATCH[1]}"
30+
age=$((current_time - vm_time))
31+
if [ $age -gt 7200 ]; then
32+
virsh undefine $vm --remove-all-storage
33+
fi
34+
fi
35+
done

tests/e2e/secretsencryption/Vagrantfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GOCOVER = (ENV['E2E_GOCOVER'] || "")
99
NODE_CPUS = (ENV['E2E_NODE_CPUS'] || 2).to_i
1010
NODE_MEMORY = (ENV['E2E_NODE_MEMORY'] || 2048).to_i
1111
# Virtualbox >= 6.1.28 require `/etc/vbox/network.conf` for expanded private networks
12-
NETWORK_PREFIX = "10.10.10"
12+
NETWORK_PREFIX = "10.10.13"
1313
install_type = ""
1414

1515
def provision(vm, role, role_num, node_num)
@@ -53,6 +53,8 @@ Vagrant.configure("2") do |config|
5353
config.vm.provider "libvirt" do |v|
5454
v.cpus = NODE_CPUS
5555
v.memory = NODE_MEMORY
56+
# We replicate the default prefix, but add a timestamp to enable parallel runs and cleanup of old VMs
57+
v.default_prefix = File.basename(Dir.getwd) + "_" + Time.now.to_i.to_s + "_"
5658
end
5759
config.vm.provider "virtualbox" do |v|
5860
v.cpus = NODE_CPUS

0 commit comments

Comments
 (0)