Kaushik Iska | ccbce98 | 2020-01-08 12:25:38 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # Copyright 2014 The Flutter Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | # This script has been adapted from: |
| 7 | # https://github.com/flutter/engine/blob/master/testing/fuchsia/run_tests.sh |
| 8 | # Any modifications made to this file might be applicable there as well. |
| 9 | |
| 10 | # This expects the device to be in zedboot mode, with a zedboot that is |
| 11 | # is compatible with the Fuchsia system image provided. |
| 12 | # |
| 13 | # The first and only parameter should be the path to the Fuchsia system image |
| 14 | # tarball, e.g. `./run_fuchsia_tests.sh generic-x64.tgz`. |
| 15 | # |
Andrew Davies | 52e0d98 | 2020-01-14 09:41:16 -0800 | [diff] [blame] | 16 | # This script expects `pm`, `device-finder`, and `fuchsia_ctl` to all be in the |
Kaushik Iska | ccbce98 | 2020-01-08 12:25:38 -0800 | [diff] [blame] | 17 | # same directory as the script. |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 18 | # |
| 19 | # This script also expects a private key available at: |
| 20 | # "/etc/botanist/keys/id_rsa_infra". |
Kaushik Iska | ccbce98 | 2020-01-08 12:25:38 -0800 | [diff] [blame] | 21 | |
Kaushik Iska | acabf9d | 2020-02-03 17:55:45 -0800 | [diff] [blame] | 22 | set -Eex |
| 23 | |
| 24 | script_dir=$(dirname "$(readlink -f "$0")") |
Kaushik Iska | ccbce98 | 2020-01-08 12:25:38 -0800 | [diff] [blame] | 25 | |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 26 | # Bot key to pave and ssh the device. |
| 27 | pkey="/etc/botanist/keys/id_rsa_infra" |
| 28 | |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 29 | # This is longer than the test timeout as dumping the |
| 30 | # logs can sometimes take longer. |
| 31 | ssh_timeout_seconds=360 |
| 32 | |
Kaushik Iska | ccbce98 | 2020-01-08 12:25:38 -0800 | [diff] [blame] | 33 | # The nodes are named blah-blah--four-word-fuchsia-id |
| 34 | device_name=${SWARMING_BOT_ID#*--} |
| 35 | |
| 36 | if [ -z "$device_name" ] |
| 37 | then |
| 38 | echo "No device found. Aborting." |
| 39 | exit 1 |
| 40 | else |
| 41 | echo "Connecting to device $device_name" |
| 42 | fi |
| 43 | |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 44 | # Wrapper function to pass common args to fuchsia_ctl. |
| 45 | fuchsia_ctl() { |
| 46 | $script_dir/fuchsia_ctl -d $device_name \ |
| 47 | --device-finder-path $script_dir/device-finder "$@" |
| 48 | } |
| 49 | |
Kaushik Iska | ccbce98 | 2020-01-08 12:25:38 -0800 | [diff] [blame] | 50 | reboot() { |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 51 | echo "$(date) START:DEVICE_LOGS ------------------------------------------" |
| 52 | fuchsia_ctl ssh \ |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 53 | --timeout-seconds $ssh_timeout_seconds \ |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 54 | --identity-file $pkey \ |
| 55 | -c "log_listener --dump_logs yes --file /tmp/log.txt" |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 56 | # As we are not using recipes we don't have a way to know the location |
| 57 | # to upload the log to isolated. We are saving the log to a file to avoid dart |
| 58 | # hanging when running the process and then just using printing the content to |
| 59 | # the console. |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 60 | fuchsia_ctl ssh \ |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 61 | --timeout-seconds $ssh_timeout_seconds \ |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 62 | --identity-file $pkey \ |
| 63 | -c "cat /tmp/log.txt" |
| 64 | echo "$(date) END:DEVICE_LOGS ------------------------------------------" |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 65 | echo "$(date) START:REBOOT ------------------------------------------" |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 66 | # note: this will set an exit code of 255, which we can ignore. |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 67 | fuchsia_ctl ssh \ |
| 68 | --identity-file $pkey \ |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 69 | -c "dm reboot-recovery" || true |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 70 | echo "$(date) END:REBOOT --------------------------------------------" |
Kaushik Iska | ccbce98 | 2020-01-08 12:25:38 -0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | trap reboot EXIT |
| 74 | |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 75 | echo "$(date) START:PAVING ------------------------------------------" |
| 76 | ssh-keygen -y -f $pkey > key.pub |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 77 | fuchsia_ctl pave -i $1 --public-key "key.pub" |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 78 | echo "$(date) END:PAVING --------------------------------------------" |
| 79 | |
Casey Hillers | ef3440b | 2020-08-31 09:48:05 -0700 | [diff] [blame] | 80 | echo "$(date) START:WAIT_DEVICE_READY -------------------------------" |
| 81 | for i in {1..10}; do |
| 82 | fuchsia_ctl ssh \ |
| 83 | --identity-file $pkey \ |
| 84 | -c "echo up" && break || sleep 15; |
| 85 | done |
| 86 | echo "$(date) END:WAIT_DEVICE_READY ---------------------------------" |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 87 | |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 88 | echo "$(date) START:PUSH_PACKAGES -------------------------------" |
Casey Hillers | 4a33ce7 | 2020-08-28 10:53:04 -0700 | [diff] [blame] | 89 | fuchsia_ctl push-packages \ |
Casey Hillers | f35a8b7 | 2020-08-26 21:33:03 -0700 | [diff] [blame] | 90 | --identity-file $pkey \ |
| 91 | --repoArchive generic-x64.tar.gz \ |
| 92 | -p tiles -p tiles_ctl |
| 93 | echo "$(date) END:PUSH_PACKAGES ---------------------------------" |
Kaushik Iska | acabf9d | 2020-02-03 17:55:45 -0800 | [diff] [blame] | 94 | |
| 95 | # set fuchsia ssh config |
Kaushik Iska | acabf9d | 2020-02-03 17:55:45 -0800 | [diff] [blame] | 96 | cat > $script_dir/fuchsia_ssh_config << EOF |
| 97 | Host * |
| 98 | CheckHostIP no |
| 99 | StrictHostKeyChecking no |
| 100 | ForwardAgent no |
| 101 | ForwardX11 no |
| 102 | GSSAPIDelegateCredentials no |
| 103 | UserKnownHostsFile /dev/null |
| 104 | User fuchsia |
| 105 | IdentitiesOnly yes |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 106 | IdentityFile $pkey |
Kaushik Iska | acabf9d | 2020-02-03 17:55:45 -0800 | [diff] [blame] | 107 | ControlPersist yes |
| 108 | ControlMaster auto |
| 109 | ControlPath /tmp/fuchsia--%r@%h:%p |
| 110 | ConnectTimeout 10 |
| 111 | ServerAliveInterval 1 |
| 112 | ServerAliveCountMax 10 |
| 113 | LogLevel ERROR |
| 114 | EOF |
| 115 | |
| 116 | export FUCHSIA_SSH_CONFIG=$script_dir/fuchsia_ssh_config |
| 117 | |
| 118 | # Run the driver test |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 119 | echo "$(date) START:DRIVER_TEST -------------------------------------" |
Kaushik Iska | acabf9d | 2020-02-03 17:55:45 -0800 | [diff] [blame] | 120 | flutter_dir=$script_dir/flutter |
| 121 | flutter_bin=$flutter_dir/bin/flutter |
| 122 | |
| 123 | # remove all out dated .packages references |
| 124 | find $flutter_dir -name ".packages" | xargs rm |
Kaushik Iska | acabf9d | 2020-02-03 17:55:45 -0800 | [diff] [blame] | 125 | cd $flutter_dir/dev/benchmarks/test_apps/stocks/ |
Kaushik Iska | acabf9d | 2020-02-03 17:55:45 -0800 | [diff] [blame] | 126 | $flutter_bin pub get |
Kaushik Iska | b16fd13 | 2020-02-06 12:04:08 -0800 | [diff] [blame] | 127 | $flutter_bin drive -v -d $device_name --target=test_driver/stock_view.dart |
godofredoc | 900c7c1 | 2020-04-22 16:48:01 -0700 | [diff] [blame] | 128 | echo "$(date) END:DRIVER_TEST ---------------------------------------" |