Skip to content

Commit

Permalink
Merge pull request #230 from bptlab/226-grpc-replayer-for-tests
Browse files Browse the repository at this point in the history
226 grpc replayer for tests
  • Loading branch information
romnn authored Apr 27, 2020
2 parents f81b292 + 5921fa9 commit ec026ef
Show file tree
Hide file tree
Showing 126 changed files with 3,740 additions and 1,250 deletions.
8 changes: 8 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ test_suite(
tags = ["smoke"],
tests = [
"//core:smoke",
"//auxiliary/producers/replayer:smoke",
"//osiris/lib:smoke",
"//osiris/auth:smoke",
"//osiris/notification:smoke",
"//osiris/query:smoke",
Expand All @@ -74,6 +76,8 @@ test_suite(
tags = ["unit"],
tests = [
"//core:unit",
"//auxiliary/producers/replayer:unit",
"//osiris/lib:unit",
"//osiris/auth:unit",
"//osiris/notification:unit",
"//osiris/query:unit",
Expand All @@ -86,6 +90,8 @@ test_suite(
tags = ["integration"],
tests = [
"//core:integration",
"//auxiliary/producers/replayer:integration",
"//osiris/lib:integration",
"//osiris/auth:integration",
"//osiris/notification:integration",
"//osiris/query:integration",
Expand All @@ -98,6 +104,8 @@ test_suite(
tags = ["internal"],
tests = [
"//core:internal",
"//auxiliary/producers/replayer:internal",
"//osiris/lib:internal",
"//osiris/auth:internal",
"//osiris/notification:internal",
"//osiris/query:internal",
Expand Down
60 changes: 52 additions & 8 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ rules_closure_dependencies(

rules_closure_toolchains()

http_archive(
name = "io_grpc_grpc_java",
sha256 = "c9ef39599b613a812843f1c43c90db9767f203b9a2ae6787f6bc715198e7dcb9",
strip_prefix = "grpc-java-1.28.1",
url = "https://github.com/grpc/grpc-java/archive/v1.28.1.zip",
)

http_archive(
name = "rules_typescript_proto",
sha256 = "0c76ae0d04eaa4d4c5f12556615cb70d294082ee672aee6dd849fea4ec2075ee",
Expand Down Expand Up @@ -135,6 +142,8 @@ RULES_JVM_EXTERNAL_TAG = "3.2"

RULES_JVM_EXTERNAL_SHA = "82262ff4223c5fda6fb7ff8bd63db8131b51b413d26eb49e3131037e79e324af"

GRPC_JAVA_VERSION = "1.28.1"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
Expand All @@ -143,15 +152,17 @@ http_archive(
)

load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")

maven_install(
artifacts = [
"org.apache.commons:commons-lang3:3.9",
"org.javatuples:javatuples:1.2",
"junit:junit:4.13",
"org.testcontainers:testcontainers:1.12.5",
"org.testcontainers:kafka:1.12.5",
"org.testcontainers:postgresql:1.12.5",
"org.testcontainers:testcontainers:1.14.1",
"org.testcontainers:kafka:1.14.1",
"org.testcontainers:postgresql:1.14.1",
"commons-io:commons-io:2.6",
"com.google.code.findbugs:jsr305:1.3.9",
"com.google.errorprone:error_prone_annotations:2.0.18",
Expand All @@ -166,12 +177,17 @@ maven_install(
"org.postgresql:postgresql:42.2.5",
"joda-time:joda-time:2.9.7",
"org.apache.kafka:kafka-clients:2.4.0",
# "io.grpc:grpc-netty-shaded:%s" % GRPC_JAVA_VERSION,
# "io.grpc:grpc-protobuf:%s" % GRPC_JAVA_VERSION,
# "io.grpc:grpc-stub:%s" % GRPC_JAVA_VERSION,
"org.apache.flink:flink-core:%s" % FLINK_VERSION,
"org.apache.flink:flink-java:%s" % FLINK_VERSION,
"org.apache.flink:flink-streaming-java_%s:%s" % (SCALA_VERSION, FLINK_VERSION),
"org.apache.flink:flink-connector-kafka-0.11_%s:%s" % (SCALA_VERSION, FLINK_VERSION),
"org.apache.flink:flink-cep_2.11:%s" % FLINK_VERSION,
],
] + IO_GRPC_GRPC_JAVA_ARTIFACTS,
generate_compat_repositories = True,
override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS,
repositories = [
"https://jcenter.bintray.com/",
"https://maven.google.com",
Expand All @@ -181,6 +197,20 @@ maven_install(
],
)

load("@maven//:compat.bzl", "compat_repositories")

compat_repositories()

load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")

# Run grpc_java_repositories after compat_repositories to ensure the
# maven_install-selected dependencies are used.
grpc_java_repositories()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

http_archive(
name = "bazel_gazelle",
urls = [
Expand Down Expand Up @@ -798,8 +828,8 @@ go_repository(
go_repository(
name = "com_github_romnnn_flags4urfavecli",
importpath = "github.com/romnnn/flags4urfavecli",
sum = "h1:1s6q1ZYyBLbh+1YrcXKaugZ6u5MSq9R763oVpkwNU2I=",
version = "v0.1.1",
sum = "h1:L7tJbR0E6zZAy+6x/PJTwJtDhkQ/338oi/E8q3Q/CE0=",
version = "v0.1.2",
)

go_repository(
Expand All @@ -812,8 +842,8 @@ go_repository(
go_repository(
name = "com_github_testcontainers_testcontainers_go",
importpath = "github.com/testcontainers/testcontainers-go",
sum = "h1:KZkEKNfnlsipJblzGCz6fmzd+0DzJ3djulYrislG3Zw=",
version = "v0.3.1",
sum = "h1:VbMekzjv6e5KmhiwMm5B1kjrCigoKYVORUVVe+QbAQc=",
version = "v0.5.1",
)

go_repository(
Expand Down Expand Up @@ -1424,3 +1454,17 @@ go_repository(
sum = "h1:zpdCK+REwbk+rqjJmHhiCN6iBIigrZ39glqSF0P3KF0=",
version = "v0.0.0-20181223230014-1083505acf35",
)

go_repository(
name = "com_github_cenkalti_backoff_v4",
importpath = "github.com/cenkalti/backoff/v4",
sum = "h1:JIufpQLbh4DkbQoii76ItQIUFzevQSqOLZca4eamEDs=",
version = "v4.0.2",
)

go_repository(
name = "com_github_romnnn_testcontainers",
importpath = "github.com/romnnn/testcontainers",
sum = "h1:n0PuOEGfc/jph4m7LA2H9NoX+HWQ8zxFyA72OqjKMoM=",
version = "v0.1.2",
)
78 changes: 53 additions & 25 deletions anubis/src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<div class="form-check form-check-inline">
<input
class="form-check-input"
v-model="replayTypeInput"
v-model="replayModeInput"
type="radio"
name="inlineRadioOptions"
id="constantReplayCheckbox"
Expand All @@ -169,7 +169,7 @@
<div class="form-check form-check-inline">
<input
class="form-check-input"
v-model="replayTypeInput"
v-model="replayModeInput"
type="radio"
name="inlineRadioOptions"
id="proportionalReplayCheckbox"
Expand Down Expand Up @@ -254,8 +254,11 @@ import NavigationBarDropdownElement from "@/components/NavbarDropdownElement.vue
import {
Speed,
ReplayStartOptions,
ReplayType,
ReplayTypeOption
ReplayMode,
ReplayOptions,
SourceReplay,
ReplaySetOptionsRequest,
ActiveReplayOptions
} from "../generated/protobuf/models/grpc/replayer_pb";
import { COOKIE_THEME } from "../constants";
Expand All @@ -275,9 +278,9 @@ export default class NavigationBar extends Vue {
search: any = null;
replaySpeed: number = 0;
replayIdsInput: string = "";
defaultReplayType: ReplayType =
ReplayType[Object.keys(ReplayType)[0] as keyof typeof ReplayType];
replayTypeInput: string = Object.keys(ReplayType)[0];
defaultReplayMode: ReplayMode =
ReplayMode[Object.keys(ReplayMode)[0] as keyof typeof ReplayMode];
replayModeInput: string = Object.keys(ReplayMode)[0];
currentTime: string = "";
private equalArrays(a1?: string[], a2?: string[]): boolean {
Expand All @@ -300,7 +303,7 @@ export default class NavigationBar extends Vue {
let speedChanged = !(
(this.replayingSpeed?.getSpeed() || 0) === this.replaySpeed
);
let typeChanged = !(this.replayingType === this.replayType);
let typeChanged = !(this.replayingType === this.replayMode);
return idsChanged || speedChanged || typeChanged;
}
Expand All @@ -313,13 +316,13 @@ export default class NavigationBar extends Vue {
);
}
get replayType(): ReplayType {
let index = this.replayTypeInput
get replayMode(): ReplayMode {
let index = this.replayModeInput
?.trim()
?.toUpperCase() as keyof typeof ReplayType;
return ReplayType[index] === undefined
? this.defaultReplayType
: ReplayType[index];
?.toUpperCase() as keyof typeof ReplayMode;
return ReplayMode[index] === undefined
? this.defaultReplayMode
: ReplayMode[index];
}
get isReplaying() {
Expand All @@ -334,20 +337,28 @@ export default class NavigationBar extends Vue {
return ReplayerModule.replayStatus;
}
get replayingIds() {
return ReplayerModule.replayingOptions?.getIdsList();
get replayingIds(): string[] {
return [
...new Set(
ReplayerModule.replayingOptions
?.getSourcesList()
?.reduce((accumulator: string[], currentValue: SourceReplay) => {
return accumulator.concat(currentValue.getIdsList());
}, [] as string[])
)
] as string[];
}
get replayingType() {
return ReplayerModule.replayingOptions?.getType();
return ReplayerModule.replayingOptions?.getOptions()?.getMode();
}
get replayingSpeed() {
return ReplayerModule.replayingOptions?.getSpeed();
return ReplayerModule.replayingOptions?.getOptions()?.getSpeed();
}
get isConstantReplay(): boolean {
return this.replayType === ReplayType.CONSTANT;
return this.replayMode === ReplayMode.CONSTANT;
}
get replayFrequencyMin(): number {
Expand Down Expand Up @@ -375,19 +386,36 @@ export default class NavigationBar extends Vue {
return AppModule.themeClass;
}
get replayOptions() {
get replayStartOptions(): ReplayStartOptions {
let options = new ReplayStartOptions();
let errids = this.replayIds || new Array<string>();
options.setIdsList(errids);
options.setType(this.replayType);
options.getSourcesList()?.forEach(s => s.setIdsList(errids));
if (!options.hasOptions()) {
options.setOptions(new ReplayOptions());
}
options.getOptions()?.setMode(this.replayMode);
if (this.scaledReplaySpeed) {
let speed = new Speed();
speed.setSpeed(this.scaledReplaySpeed);
options.setSpeed(speed);
options.getOptions()?.setSpeed(speed);
}
return options;
}
get replayUpdateOptions() {
let updateOptions = new ReplaySetOptionsRequest();
let replayOptions = new ActiveReplayOptions();
let options = this.replayStartOptions.getOptions();
if (options) {
replayOptions.setSpeed(options.getSpeed());
replayOptions.setMode(options.getMode());
replayOptions.setTimerange(options.getTimerange());
replayOptions.setRepeat(options.getRepeat());
}
updateOptions.setOptions(replayOptions);
return updateOptions;
}
dateLocale: string = "en-GB";
timezone: number = 0;
timezones: Array<string> = ["UTC", "EET", "WET", "CET"];
Expand Down Expand Up @@ -426,11 +454,11 @@ export default class NavigationBar extends Vue {
}
toggleReplay() {
ReplayerModule.toggleReplayer(this.replayOptions);
ReplayerModule.toggleReplayer(this.replayStartOptions);
}
updateReplay() {
ReplayerModule.setReplayOptions(this.replayOptions);
ReplayerModule.setReplayOptions(this.replayUpdateOptions);
}
resetReplay() {
Expand Down
Loading

0 comments on commit ec026ef

Please sign in to comment.