blob: 3b6674e5ebf5b7ab7c758c22ab02df18f322908c [file] [log] [blame]
Leopold Schabel383d4bb2019-11-14 22:53:58 +01001#!/usr/bin/expect -f
2
Leopold Schabela4516f92019-12-04 20:27:05 +00003# Getting the actual path from a sh_test rule is not straight-forward and would involve
4# parsing the runfile at $RUNFILES_DIR, so just hardcode it.
5#
6# We'll want to replace this thing by a proper e2e testing suite sooner than we'll
7# have to worry about cross-compilation or varying build environments.
8#
9# (see https://github.com/bazelbuild/bazel/blob/master/tools/bash/runfiles/runfiles.bash)
10set kubectl_path "external/kubernetes/cmd/kubectl/linux_amd64_pure_stripped/kubectl"
11
Leopold Schabelf79bfac2019-11-18 11:16:39 +010012set timeout 60
Leopold Schabel383d4bb2019-11-14 22:53:58 +010013
Leopold Schabela4516f92019-12-04 20:27:05 +000014proc print_stderr {msg} {
15 send_error "\[TEST\] $msg\n"
16}
17
Leopold Schabel383d4bb2019-11-14 22:53:58 +010018spawn core/scripts/launch.sh
19
20expect "Network service got IP" {} default {
Leopold Schabela4516f92019-12-04 20:27:05 +000021 print_stderr "Failed while waiting for IP address\n"
Leopold Schabel383d4bb2019-11-14 22:53:58 +010022 exit 1
23}
24
Leopold Schabela4516f92019-12-04 20:27:05 +000025expect "Initialized encrypted storage" {} default {
26 print_stderr "Failed while waiting for encrypted storage\n"
Leopold Schabel383d4bb2019-11-14 22:53:58 +010027 exit 1
28}
Leopold Schabela4516f92019-12-04 20:27:05 +000029
30print_stderr "Calling api.SetupService.Setup\n"
31system "grpc_cli --channel_creds_type=insecure call localhost:7833 api.SetupService.Setup -json_input '{\"nodeName\": \"node-1\"}'"
32
33print_stderr "Calling api.SetupService.BootstrapNewCluster\n"
34system "grpc_cli --channel_creds_type=insecure call localhost:7833 api.SetupService.BootstrapNewCluster ''"
35
36# Make an educated guess if the control plane came up
37expect -timeout 3 "\n" {
38 exp_continue
39} timeout {} default {
40 print_stderr "Failed while waiting for k8s control plane\n"
41 exit 1
42}
43
44spawn $kubectl_path cluster-info dump -s https://localhost:6443 --username none --password none --insecure-skip-tls-verify=true
45
46expect "User \"system:anonymous\" cannot list resource \"nodes\" in API group \"\" at the cluster scope" {} default {
47 print_stderr "Failed while waiting for encrypted storage\n"
48 exit 1
49}
50
51print_stderr "Completed successfully"
52exit 0