Skip to content
Snippets Groups Projects
  • Chase Qi's avatar
    b0793e7d
    ci: enable LAVA boot and smoke tests on qemu devices for new MRs · b0793e7d
    Chase Qi authored
    
    Given test scope for new MRs is not defined yet and we only have one
    rpi4, b68 and c61 in the warsaw lab which are occupied mostly by daily
    scheduled pipeline, starting with boot and smoke tests on qemu devices
    should be a good starting point for per MR testing.
    
    Jobs that extend `.lava-test` will be added to MR's pipeline and
    schedueld pipeline.
    
    `.lava-test-scheduled` extends `.lava-test` with new scheduled pipeline
    only rule. Long run jobs like ltp should extends the job so that they
    wouldn't prevent MRs from merging.
    
    Solves #486.
    
    Signed-off-by: default avatarChase Qi <chase.qi@linaro.org>
    b0793e7d
    History
    ci: enable LAVA boot and smoke tests on qemu devices for new MRs
    Chase Qi authored
    
    Given test scope for new MRs is not defined yet and we only have one
    rpi4, b68 and c61 in the warsaw lab which are occupied mostly by daily
    scheduled pipeline, starting with boot and smoke tests on qemu devices
    should be a good starting point for per MR testing.
    
    Jobs that extend `.lava-test` will be added to MR's pipeline and
    schedueld pipeline.
    
    `.lava-test-scheduled` extends `.lava-test` with new scheduled pipeline
    only rule. Long run jobs like ltp should extends the job so that they
    wouldn't prevent MRs from merging.
    
    Solves #486.
    
    Signed-off-by: default avatarChase Qi <chase.qi@linaro.org>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test-generic.yaml 6.96 KiB
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Huawei Inc.

##
## Submits a job to LAVA with CI variables
##
.lava-test:
  interruptible: true
  image:
    name: registry.ostc-eu.org/ostc/oniro/bitbake-builder:latest
  variables:
    GIT_STRATEGY: none
    CI_LAVA_INSTANCE: "https://lava.ostc-eu.org/"
    CI_SQUAD_INSTANCE: "https://squadp.svc.ostc-eu.dev"
    CI_SQUAD_PROJECT_NAME: "oniro-test-mr"
    # Run the same ltp test suites that using by LKFT project.
    # Reference: https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.10.y/build/v5.10.98-75-g9f5cb871ceb9/testjobs/
    LTP_TST_CMDFILES: "cap_bounds cpuhotplug crypto nptl pty securebits fs controllers hugetlb mm tracing containers io dio syscalls math commands ipc fcntl-locktests filecaps fs_bind fs_perms_simple fsx sched cve"
  before_script:
    - test -n "$CI_LAVA_TOKEN" || (
        echo "precondition failed - please disable the child job if CI_LAVA_TOKEN not set in gitlab CI/CD variables"
        && exit 1 )
    # Check if the job is configured properly.
    - test -n "$MACHINE" || (
        echo "precondition failed - set MACHINE to the name of the target device for which the image is built"
        && exit 1 )
    - test -n "$CI_BUILD_JOB_NAME" || (
        echo "precondition failed - set CI_BUILD_JOB_NAME to the appropriate job name from which LAVA will pick up build artifact"
        && exit 1 )
    - test -n "$CI_LAVA_JOB_DEFINITION" || (
        echo "precondition failed - set CI_LAVA_JOB_DEFINITION to the URL of the LAVA test job definition"
        && exit 1 )
    - test -n "$CI_REPORT_JOB_NAME" || (
        echo "precondition failed - set CI_REPORT_JOB_NAME to the CI job name which will gather results back from LAVA"
        && exit 1 )
  script:
    # Build callback URL for the "report" job
    - curl --silent "$CI_API_V4_URL/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs?per_page=100" > jobs-manual.json
    - job_id="$(jq -r ".[] | select(.name == \"$CI_REPORT_JOB_NAME\") | .id" jobs-manual.json)"
    - build_job_id="$(jq -r ".[] | select(.name == \"$CI_BUILD_JOB_NAME\") | .id" jobs-manual.json)"
    - CALLBACK_URL="$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/${job_id}/play"
    # Get the job definition from remote source.
    - curl --silent "$CI_LAVA_JOB_DEFINITION" > job_def.yaml
    # Update the job definition with CI data.
    - sed -i -e 's/@ci_job_id@/'"$CI_JOB_ID"'/'
      -e 's/@ci_project_id@/'"$CI_PROJECT_ID"'/'
      -e 's/@ci_pipeline_id@/'"$CI_PIPELINE_ID"'/'
      -e 's,@ci_pipeline_url@,'"$CI_PIPELINE_URL"','
      -e 's/@build_job_id@/'"$build_job_id"'/' job_def.yaml
    # Generate test jobs.
    - |
      set -x
      rm -rf lava_jobs && mkdir lava_jobs
      # Generate job definitions for zephyr build
      if echo "${CI_BUILD_JOB_NAME}" | grep -i "zephyr" | grep -vi "twister"; then
        for image in $(find artifacts/images/${MACHINE} -name "*.elf" -exec basename {} \;); do
          image_basename=$(basename "${image}" ".elf")
          echo "--- Generating lava job definition ${image_basename}.yaml ---"
          sed "s/@image_basename@/$image_basename/" job_def.yaml | tee lava_jobs/"${image_basename}".yaml
        done
      # Generate job definitions for linux LTP test.
      elif grep -q "@TST_CMDFILES@" job_def.yaml; then
        for test_cmdfile in ${LTP_TST_CMDFILES}; do
          ltp_job_name="ltp-${test_cmdfile}.yaml"
          echo "--- Generating lava job definition ${ltp_job_name} ---"
          sed "s/@TST_CMDFILES@/${test_cmdfile}/" job_def.yaml | tee lava_jobs/"${ltp_job_name}"
        done
      else
        mv job_def.yaml lava_jobs/
      fi