Test Lab ট্রিগার (ফার্স্ট জেনারেশন)

TestMatrix সম্পূর্ণ হলে কোনও ফাংশন ট্রিগার করা

TestMatrix ইভেন্ট হ্যান্ডলার functions.testLab.testMatrix().onComplete() সম্পূর্ণ হলে ট্রিগার করে এমন একটি নতুন ফাংশন তৈরি করুন:

exports.sendEmailNotification = functions.testLab.testMatrix().onComplete((testMatrix) => {
  // ...
});

টেস্টের স্ট্যাটাস ও ফলাফল ম্যানেজ করা

আপনার ফাংশনের প্রতিটি এক্সিকিউশনে একটি TestMatrix পাস করা হয় যার মধ্যে ম্যাট্রিক্সের চূড়ান্ত অবস্থা এবং সমস্যা বুঝতে সাহায্য করার জন্য বিবরণ অন্তর্ভুক্ত থাকে।

exports.handleTestMatrixCompletion = functions.testLab.testMatrix().onComplete(testMatrix => {
  const matrixId = testMatrix.testMatrixId;
  switch (testMatrix.state) {
    case 'FINISHED':
      console.log(`TestMatrix ${matrixId} finished with outcome: ${testMatrix.outcomeSummary}`);
      break;
    case 'INVALID':
      console.log(`TestMatrix ${matrixId} was marked as invalid: ${testMatrix.invalidMatrixDetails}`);
      break;
    default:
      console.log(`TestMatrix ${matrixId} completed with state ${testMatrix.state}`);
  }
  return null;
});

ক্লায়েন্টের বিবরণ অ্যাক্সেস করা

বিভিন্ন সোর্স বা ওয়ার্কফ্লো থেকে টেস্ট ম্যাট্রিক্স তৈরি করা হতে পারে। তাই, সোর্স বা পরীক্ষার অন্যান্য গুরুত্বপূর্ণ কনটেক্সটের উপর ভিত্তি করে বিভিন্ন অ্যাকশন পারফর্ম করে এমন ফাংশন তৈরি করা প্রায়ই কাম্য। এই ব্যাপারে সাহায্য করতে, gcloud আপনাকে টেস্ট শুরু করার সময় যেকোনও তথ্য পাস করার অনুমতি দেয় যা পরে আপনার ফাংশনে অ্যাক্সেস করা যেতে পারে। যেমন:

gcloud beta firebase test android run \
    --app=path/to/app.apk \
    --client-details testType=pr,link=https://path/to/pull-request

ফাংশনের উদাহরণ:

exports.notifyOnPullRequestFailure = functions.testLab.testMatrix().onComplete(testMatrix => {
  if (testMatrix.clientInfo.details['testType'] != 'pr') {
    // Not a pull request
    return null;
  }

  if (testMatrix.state == 'FINISHED' && testMatrix.outcomeSummary == 'SUCCESS') {
    // No failure
    return null;
  }

  const link = testMatrix.clientInfo.details['link'];
  let message = `Test Lab validation for pull request ${link} failed. `;

  if (!!testMatrix.resultStorage.resultsUrl) {
    message += `Test results available at ${testMatrix.resultStorage.resultsUrl}. `;
  }

  // Send notification here ...
});