Search in sources :

Example 21 with PreconditionFailure

use of com.google.rpc.PreconditionFailure in project bazel-buildfarm by bazelbuild.

the class AbstractServerInstanceTest method absoluteWorkingDirectoryIsInvalid.

@Test
public void absoluteWorkingDirectoryIsInvalid() {
    AbstractServerInstance instance = new DummyServerInstance();
    PreconditionFailure.Builder preconditionFailureBuilder = PreconditionFailure.newBuilder();
    instance.validateCommand(Command.newBuilder().addArguments("foo").setWorkingDirectory("/var/lib/db").build(), DIGEST_UTIL.empty(), ImmutableSet.of(), ImmutableSet.of(), ImmutableMap.of(), preconditionFailureBuilder);
    PreconditionFailure preconditionFailure = preconditionFailureBuilder.build();
    assertThat(preconditionFailure.getViolationsCount()).isEqualTo(1);
    Violation violation = preconditionFailure.getViolationsList().get(0);
    assertThat(violation.getType()).isEqualTo(VIOLATION_TYPE_INVALID);
    assertThat(violation.getSubject()).isEqualTo(INVALID_COMMAND);
    assertThat(violation.getDescription()).isEqualTo("working directory is absolute");
}
Also used : Violation(com.google.rpc.PreconditionFailure.Violation) PreconditionFailure(com.google.rpc.PreconditionFailure) Test(org.junit.Test)

Example 22 with PreconditionFailure

use of com.google.rpc.PreconditionFailure in project bazel-buildfarm by bazelbuild.

the class AbstractServerInstanceTest method duplicateDirectoryInputIsInvalid.

@Test
public void duplicateDirectoryInputIsInvalid() {
    Directory emptyDirectory = Directory.getDefaultInstance();
    Digest emptyDirectoryDigest = DIGEST_UTIL.compute(emptyDirectory);
    PreconditionFailure.Builder preconditionFailure = PreconditionFailure.newBuilder();
    AbstractServerInstance.validateActionInputDirectory(ACTION_INPUT_ROOT_DIRECTORY_PATH, Directory.newBuilder().addAllDirectories(ImmutableList.of(DirectoryNode.newBuilder().setName("foo").setDigest(emptyDirectoryDigest).build(), DirectoryNode.newBuilder().setName("foo").setDigest(emptyDirectoryDigest).build())).build(), /* pathDigests=*/
    new Stack<>(), /* visited=*/
    Sets.newHashSet(), /* directoriesIndex=*/
    ImmutableMap.of(emptyDirectoryDigest, emptyDirectory), /* onInputFiles=*/
    file -> {
    }, /* onInputDirectories=*/
    directory -> {
    }, /* onInputDigests=*/
    digest -> {
    }, preconditionFailure);
    assertThat(preconditionFailure.getViolationsCount()).isEqualTo(1);
    assertThat(preconditionFailure.getViolationsCount()).isEqualTo(1);
    Violation violation = preconditionFailure.getViolationsList().get(0);
    assertThat(violation.getType()).isEqualTo(VIOLATION_TYPE_INVALID);
    assertThat(violation.getSubject()).isEqualTo("/: foo");
    assertThat(violation.getDescription()).isEqualTo(DUPLICATE_DIRENT);
}
Also used : Violation(com.google.rpc.PreconditionFailure.Violation) PreconditionFailure(com.google.rpc.PreconditionFailure) Digest(build.bazel.remote.execution.v2.Digest) OutputDirectory(build.bazel.remote.execution.v2.OutputDirectory) Directory(build.bazel.remote.execution.v2.Directory) Test(org.junit.Test)

Example 23 with PreconditionFailure

use of com.google.rpc.PreconditionFailure in project bazel-buildfarm by bazelbuild.

the class AbstractServerInstanceTest method nestedOutputDirectoriesAreInvalid.

@Test
public void nestedOutputDirectoriesAreInvalid() {
    PreconditionFailure.Builder preconditionFailureBuilder = PreconditionFailure.newBuilder();
    AbstractServerInstance.validateOutputs(ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of("foo", "foo/bar"), preconditionFailureBuilder);
    PreconditionFailure preconditionFailure = preconditionFailureBuilder.build();
    assertThat(preconditionFailure.getViolationsCount()).isEqualTo(1);
    Violation violation = preconditionFailure.getViolationsList().get(0);
    assertThat(violation.getType()).isEqualTo(VIOLATION_TYPE_INVALID);
    assertThat(violation.getSubject()).isEqualTo("foo");
    assertThat(violation.getDescription()).isEqualTo(OUTPUT_DIRECTORY_IS_OUTPUT_ANCESTOR);
}
Also used : Violation(com.google.rpc.PreconditionFailure.Violation) PreconditionFailure(com.google.rpc.PreconditionFailure) Test(org.junit.Test)

Example 24 with PreconditionFailure

use of com.google.rpc.PreconditionFailure in project bazel-buildfarm by bazelbuild.

the class AbstractServerInstanceTest method outputDirectoriesContainingOutputFilesAreInvalid.

@Test
public void outputDirectoriesContainingOutputFilesAreInvalid() {
    PreconditionFailure.Builder preconditionFailureBuilder = PreconditionFailure.newBuilder();
    AbstractServerInstance.validateOutputs(ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of("foo/bar"), ImmutableSet.of("foo"), preconditionFailureBuilder);
    PreconditionFailure preconditionFailure = preconditionFailureBuilder.build();
    assertThat(preconditionFailure.getViolationsCount()).isEqualTo(1);
    Violation violation = preconditionFailure.getViolationsList().get(0);
    assertThat(violation.getType()).isEqualTo(VIOLATION_TYPE_INVALID);
    assertThat(violation.getSubject()).isEqualTo("foo");
    assertThat(violation.getDescription()).isEqualTo(OUTPUT_DIRECTORY_IS_OUTPUT_ANCESTOR);
}
Also used : Violation(com.google.rpc.PreconditionFailure.Violation) PreconditionFailure(com.google.rpc.PreconditionFailure) Test(org.junit.Test)

Example 25 with PreconditionFailure

use of com.google.rpc.PreconditionFailure in project bazel-buildfarm by bazelbuild.

the class Cat method printStatus.

private static void printStatus(com.google.rpc.Status status) throws InvalidProtocolBufferException {
    System.out.println("  Code: " + Code.forNumber(status.getCode()));
    if (!status.getMessage().isEmpty()) {
        System.out.println("  Message: " + status.getMessage());
    }
    if (status.getDetailsCount() > 0) {
        System.out.println("  Details:");
        for (Any detail : status.getDetailsList()) {
            if (detail.is(RetryInfo.class)) {
                RetryInfo retryInfo = detail.unpack(RetryInfo.class);
                System.out.println("    RetryDelay: " + (retryInfo.getRetryDelay().getSeconds() + retryInfo.getRetryDelay().getNanos() / 1000000000.0f));
            } else if (detail.is(PreconditionFailure.class)) {
                PreconditionFailure preconditionFailure = detail.unpack(PreconditionFailure.class);
                System.out.println("    PreconditionFailure:");
                for (PreconditionFailure.Violation violation : preconditionFailure.getViolationsList()) {
                    System.out.println("      Violation: " + violation.getType());
                    System.out.println("        Subject: " + violation.getSubject());
                    System.out.println("        Description: " + violation.getDescription());
                }
            } else {
                System.out.println("    Unknown Detail: " + detail.getTypeUrl());
            }
        }
    }
}
Also used : PreconditionFailure(com.google.rpc.PreconditionFailure) Any(com.google.protobuf.Any) RetryInfo(com.google.rpc.RetryInfo)

Aggregations

PreconditionFailure (com.google.rpc.PreconditionFailure)26 Test (org.junit.Test)18 Digest (build.bazel.remote.execution.v2.Digest)13 Violation (com.google.rpc.PreconditionFailure.Violation)12 ExecuteResponse (build.bazel.remote.execution.v2.ExecuteResponse)10 ByteString (com.google.protobuf.ByteString)9 Action (build.bazel.remote.execution.v2.Action)8 Directory (build.bazel.remote.execution.v2.Directory)6 Actions.checkPreconditionFailure (build.buildfarm.common.Actions.checkPreconditionFailure)6 Poller (build.buildfarm.common.Poller)6 ExecuteEntry (build.buildfarm.v1test.ExecuteEntry)6 Operation (com.google.longrunning.Operation)6 Status (io.grpc.Status)6 ExecutionException (java.util.concurrent.ExecutionException)6 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)5 ExecuteOperationMetadata (build.bazel.remote.execution.v2.ExecuteOperationMetadata)4 Watcher (build.buildfarm.common.Watcher)4 Any (com.google.protobuf.Any)4 QueueEntry (build.buildfarm.v1test.QueueEntry)3 QueuedOperation (build.buildfarm.v1test.QueuedOperation)3