use of com.google.rpc.PreconditionFailure.Violation in project bazel-buildfarm by bazelbuild.
the class AbstractServerInstanceTest method outputFilesAsOutputDirectoryAncestorsAreInvalid.
@Test
public void outputFilesAsOutputDirectoryAncestorsAreInvalid() {
PreconditionFailure.Builder preconditionFailureBuilder = PreconditionFailure.newBuilder();
AbstractServerInstance.validateOutputs(ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of("foo"), ImmutableSet.of("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_FILE_IS_OUTPUT_ANCESTOR);
}
use of com.google.rpc.PreconditionFailure.Violation in project bazel-buildfarm by bazelbuild.
the class AbstractServerInstanceTest method unsortedFileInputIsInvalid.
@Test
public void unsortedFileInputIsInvalid() {
PreconditionFailure.Builder preconditionFailure = PreconditionFailure.newBuilder();
AbstractServerInstance.validateActionInputDirectory(ACTION_INPUT_ROOT_DIRECTORY_PATH, Directory.newBuilder().addAllFiles(ImmutableList.of(FileNode.newBuilder().setName("foo").build(), FileNode.newBuilder().setName("bar").build())).build(), /* pathDigests=*/
new Stack<>(), /* visited=*/
Sets.newHashSet(), /* directoriesIndex=*/
Maps.newHashMap(), /* onInputFiles=*/
file -> {
}, /* onInputDirectories=*/
directory -> {
}, /* onInputDigests=*/
digest -> {
}, preconditionFailure);
assertThat(preconditionFailure.getViolationsCount()).isEqualTo(1);
Violation violation = preconditionFailure.getViolationsList().get(0);
assertThat(violation.getType()).isEqualTo(VIOLATION_TYPE_INVALID);
assertThat(violation.getSubject()).isEqualTo("/: foo > bar");
assertThat(violation.getDescription()).isEqualTo(DIRECTORY_NOT_SORTED);
}
use of com.google.rpc.PreconditionFailure.Violation in project bazel-buildfarm by bazelbuild.
the class AbstractServerInstanceTest method emptyArgumentListIsInvalid.
@Test
public void emptyArgumentListIsInvalid() {
AbstractServerInstance instance = new DummyServerInstance();
PreconditionFailure.Builder preconditionFailureBuilder = PreconditionFailure.newBuilder();
instance.validateCommand(Command.getDefaultInstance(), 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("argument list is empty");
}
use of com.google.rpc.PreconditionFailure.Violation 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");
}
use of com.google.rpc.PreconditionFailure.Violation 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);
}
Aggregations