/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
syntax = "proto3";

package com.android.tradefed.isolation;

option java_multiple_files = true;
option java_package = "com.android.tradefed.isolation";
option java_outer_classname = "IsolationRunnerProto";

enum RunnerOp {
  RUNNER_OP_UNSPECIFIED = 0;
  RUNNER_OP_STOP = 1;
  RUNNER_OP_RUN_TEST = 2;
}

enum RunnerStatus {
  RUNNER_STATUS_UNSPECIFIED = 0;
  RUNNER_STATUS_STARTING = 1;
  RUNNER_STATUS_FINISHED_OK = 2;
  RUNNER_STATUS_FINISHED_ERROR = 3;
}

enum TestStatus {
  TEST_STATUS_UNSPECIFIED = 0;
  TEST_STATUS_STARTED = 1;
  TEST_STATUS_FINISHED_OK = 2;
  TEST_STATUS_FINISHED_ERROR = 3;
  TEST_STATUS_RUN_STARTED = 4;
  TEST_STATUS_RUN_FINISHED = 5;
}

message TestParameters {
  repeated string testClasses = 1;
  repeated string testJarAbsPaths = 2;
  repeated string excludePaths = 3;
  FilterSpec filter = 4;
  bool dryRun = 5;
  int32 totalShards = 6;
  int32 shardIndex = 7;

}

message FilterSpec {
  repeated string includeFilters = 1;
  repeated string excludeFilters = 2;
  repeated string includeAnnotations = 3;
  repeated string excludeAnnotations = 4;
}

enum Topic {
  TOPIC_UNSPECIFIED = 0;
  TOPIC_FAILURE = 1;
  TOPIC_ASSUMPTION_FAILURE = 2;
  TOPIC_STARTED = 3;
  TOPIC_FINISHED = 4;
  TOPIC_IGNORED = 5;
  TOPIC_RUN_STARTED = 6;
  TOPIC_RUN_FINISHED = 7;
  TOPIC_SUITE_STARTED = 8;
  TOPIC_SUITE_FINISHED = 9;
}

message JUnitEvent {
  Topic topic = 1;
  string message = 2;
  string method_name = 3;
  string class_name = 4;
  string suite_name = 5;
  int32 test_count = 6;
  int64 elapsed_time = 7;
  // The start time of the event if applicable in millisecond since epoch
  int64 start_time = 8;
  // The end time of the event if applicable in millisecond since epoch
  int64 end_time = 9;
}

message RunnerMessage {
  RunnerOp command = 1;
  TestParameters params = 2;
}

message RunnerReply {
  RunnerStatus runnerStatus = 1;
  JUnitEvent testEvent = 2;
  string message = 3;
}