# submission YAML prototype for connecting to a cubietruck over ssh
# as secondary connection.
# whichever role is operating as the "host" must specify how to
# authorize connections from other roles using the authorize: key
# in the deployment. This allows the relevant Action to deploy the
# necessary support. e.g. /root/.ssh/authorized_keys

job_name: hikey-libhugetlbfs-secondary
timeouts:
  job:
    minutes: 30
  action:
    minutes: 3
  connection:
    minutes: 5

protocols:
  lava-multinode:
    # expect_role is used by the dispatcher and is part of delay_start
    # host_role is used by the scheduler, unrelated to delay_start.
    roles:
      guest:
        # no device_type, just a connection
        connection: ssh
        count: 1
        # set the role for which this role will wait
        expect_role: host
        # each ssh connection will attempt to connect to the device of role 'host'
        host_role: host
        # protocol API call to make during protocol setup
        request: lava-start
        timeout:
          minutes: 15
      host:
        device_type: hi6220-hikey
        count: 1
        timeout:
          minutes: 10
  lava-lxc:
    name: lxc-hikey-oe
    template: debian
    distribution: debian
    release: jessie
    arch: amd64
    mirror: http://mirror.bytemark.co.uk/debian

priority: medium
visibility: public

actions:
- deploy:
    namespace: tlxc
    timeout:
      minutes: 15
    to: lxc
    packages:
    - android-tools-fastboot
    os: debian
- boot:
    namespace: tlxc
    prompts:
    - 'root@(.*):/#'
    - 'hikey:/'
    timeout:
      minutes: 5
    method: lxc
- deploy:
    role:
    - host
    timeout:
      minutes: 15
    to: fastboot
    namespace: hikey-oe
    connection: lxc
    images:
      ptable:
        url: http://releases.linaro.org/reference-platform/embedded/hikey/16.12/rpb/bootloader/ptable-linux-8g.img
        reboot: hard-reset
      boot:
        url: https://snapshots.linaro.org/openembedded/lkft/morty/hikey/rpb/linux-mainline/latest/boot-0.0+AUTOINC+06e4def583-fb1158a365-r0-hikey-20170717222154-98.uefi.img
        reboot: hard-reset
      system:
        url: https://snapshots.linaro.org/openembedded/lkft/morty/hikey/rpb/linux-mainline/latest/rpb-console-image-hikey-20170717222154-98.rootfs.img.gz
        compression: gz
        apply-overlay: true
        # ensure that this job raises a network interface with DHCP before relying on internet access
    os: oe
    protocols:
      lava-lxc:
      - action: fastboot-deploy
        request: pre-power-command
        timeout:
          minutes: 2
- boot:
    role:
    - host
    namespace: hikey-oe
    auto_login:
      login_prompt: 'login:'
      username: linaro
      login_commands:
        # Become super user to run tests
        - su
    prompts:
    - 'hikey:~'
    - 'root@(.*):/#'
    timeout:
      minutes: 5
    method: uefi-menu
    commands: fastboot
    protocols:
      lava-lxc:
      # other action could be boot-fastboot
      - action: uefi-commands
        request: pre-os-command
        timeout:
          minutes: 2
- test:
    role:
    - host
    namespace: hikey-oe
    timeout:
      minutes: 60
    definitions:
    - from: inline
      repository:
        metadata:
          format: Lava-Test Test Definition 1.0
          name: prep-tests
          description: "Basic network tests"
        run:
          steps:
          # the image does not raise the interface itself
          # force a DHCP request to avoid avahi using a zero conf address.
          - udhcpc
          - netstat
          - ip a
          - ifconfig
          - df
          - cat /sys/class/thermal/thermal_zone0/policy || true
          - echo "power_allocator" > /sys/class/thermal/thermal_zone0/policy || true
          - cat /sys/class/thermal/thermal_zone0/policy || true
          - timeout 30m dmesg -e -w || true
      name: prep-inline
      path: inline/prep.yaml

- test:
   namespace: tlxc
   timeout:
     minutes: 5
   definitions:
    - from: inline
      repository:
        metadata:
          format: Lava-Test Test Definition 1.0
          name: dummy-tests
          description: "Dummy tests"
        run:
          steps:
          - ls
      name: dummy-test
      path: inline/dummy.yaml

- deploy:
    role:
    - guest
    connection: ssh
    os: oe
    protocols:
      lava-multinode:
      - action: prepare-scp-overlay
        request: lava-wait
        # messageID matches hostID
        messageID: ipv4
        message:
          # the key of the message matches value of the host_key
          # the value of the message gets substituted
          ipaddr: $ipaddr
        timeout:  # delay_start timeout
          minutes: 5
    timeout:  # timeout for the ssh connection attempt
      seconds: 30
    to: ssh

- boot:
    role:
    - guest
    method: ssh
    prompts:
    - 'root@linaro:'
    parameters:
      hostID: ipv4  # messageID
      host_key: ipaddr  # message key
    timeout:
      minutes: 3

- test:
    role:
    - guest
    timeout:
      minutes: 5
    definitions:
    - repository: git://git.linaro.org/qa/test-definitions.git
      from: git
      path: automated/linux/libhugetlbfs/libhugetlbfs.yaml
      name: libhugetlbfs
      timeout:
        minutes: 30
