ক্লাউড ফাংশন সহ Firebase টেস্ট ল্যাব প্রসারিত করুন


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 ...
});