Search in sources :

Example 1 with ShardStats

use of com.google.idea.blaze.base.logging.utils.ShardStats in project intellij by bazelbuild.

the class BlazeBuildTargetSharderTest method expandAndShardTargets_expandWildcardTargets.

@Test
public void expandAndShardTargets_expandWildcardTargets() {
    String expectedLabel1 = "//java/com/google:one";
    String expectedLabel2 = "//java/com/google:two";
    fakeWildCardTargetExpanderExternalTaskProvider.setReturnVal(0).setOutputMessage("sh_library rule " + expectedLabel1, "sh_library rule " + expectedLabel2);
    fakeBuildBatchingService.setShardingApproach(ShardingApproach.LEXICOGRAPHIC_TARGET_SHARDER).setFailToBatchTarget(false);
    List<TargetExpression> targets = ImmutableList.of(target("//java/com/google/..."));
    ShardedTargetsResult result = expandAndShardTargets(SyncStrategy.PARALLEL, ProjectView.builder().add(ScalarSection.builder(ShardBlazeBuildsSection.KEY).set(true)).add(ScalarSection.builder(TargetShardSizeSection.KEY).set(500)).build(), targets);
    ShardStats shardStats = result.shardedTargets.shardStats;
    assertThat(shardStats.suggestedTargetSizePerShard()).isEqualTo(500);
    assertThat(shardStats.actualTargetSizePerShard()).containsExactly(2);
    assertThat(result.shardedTargets.shardedTargets).containsExactly(ImmutableList.of(target(expectedLabel1), target(expectedLabel2)));
}
Also used : ShardStats(com.google.idea.blaze.base.logging.utils.ShardStats) ShardedTargetsResult(com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder.ShardedTargetsResult) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Example 2 with ShardStats

use of com.google.idea.blaze.base.logging.utils.ShardStats in project intellij by bazelbuild.

the class BlazeBuildTargetSharderTest method expandAndShardTargets_localBuild_buildBatchingServiceIsUsed.

@Test
public void expandAndShardTargets_localBuild_buildBatchingServiceIsUsed() {
    fakeBuildBatchingService.setShardingApproach(ShardingApproach.LEXICOGRAPHIC_TARGET_SHARDER).setFailToBatchTarget(false);
    List<TargetExpression> targets = ImmutableList.of(target("//java/com/google:foo"));
    ShardedTargetsResult result = expandAndShardTargets(SyncStrategy.PARALLEL, ProjectView.builder().add(ScalarSection.builder(ShardBlazeBuildsSection.KEY).set(true)).add(ScalarSection.builder(TargetShardSizeSection.KEY).set(500)).build(), targets);
    assertThat(result.buildResult.exitCode).isEqualTo(0);
    ShardStats shardStats = result.shardedTargets.shardStats;
    assertThat(shardStats.shardingApproach()).isEqualTo(ShardingApproach.LEXICOGRAPHIC_TARGET_SHARDER);
}
Also used : ShardStats(com.google.idea.blaze.base.logging.utils.ShardStats) ShardedTargetsResult(com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder.ShardedTargetsResult) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Test(org.junit.Test)

Aggregations

ShardStats (com.google.idea.blaze.base.logging.utils.ShardStats)2 TargetExpression (com.google.idea.blaze.base.model.primitives.TargetExpression)2 ShardedTargetsResult (com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder.ShardedTargetsResult)2 Test (org.junit.Test)2