Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Updating execution files + adding index.ts #20

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8101a96
big commit to make the execution files compile, but still TODOs left
GoodMorningA1i Aug 22, 2021
b07e067
added index.ts with necessary exports
GoodMorningA1i Aug 23, 2021
79b6458
small update to TODO comment
GoodMorningA1i Aug 23, 2021
247046d
update the package.json to remove build/typescript and replace with b…
GoodMorningA1i Aug 23, 2021
82c46b4
updated the server files to consider unimplemented server requirements
GoodMorningA1i Aug 23, 2021
51aa20d
self-review of this PR
GoodMorningA1i Aug 24, 2021
2e396c1
updated this local branch with latest porting of kurtosis-testsuite-a…
GoodMorningA1i Aug 24, 2021
f852ba9
imported KnownKeysOnly from minimal-grpc-server
GoodMorningA1i Aug 24, 2021
212800d
iterated on Kevin's feedback part 1
GoodMorningA1i Aug 24, 2021
22ad19f
indentation solves
GoodMorningA1i Aug 24, 2021
e09bcf2
trying to fix .then indenting issues + adding ServiceError class
GoodMorningA1i Aug 24, 2021
1d50229
dealt with mutexes
GoodMorningA1i Aug 24, 2021
cc3a130
cleaned up metadata providing service file as well with proper servic…
GoodMorningA1i Aug 24, 2021
b2c5a78
fixing indentations
GoodMorningA1i Aug 24, 2021
c0c7d70
trying to fix indentations
GoodMorningA1i Aug 24, 2021
1304e71
removed ServiceError and iterating on Kevin's final comments
GoodMorningA1i Aug 25, 2021
2dbfaeb
fixed all the tab issues inside of my files
GoodMorningA1i Aug 25, 2021
18e74ad
fixing defer functionality + async/sync mess
GoodMorningA1i Aug 25, 2021
893ad4a
Merge branch 'GoodMorningA1i/porting-testuite-api-lib-to-typescript' …
GoodMorningA1i Aug 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@
"grpc": "^1.24.11",
"kurtosis-core-api-lib": "^0.13.1",
"loglevel": "^1.7.1",
"minimal-grpc-server": "^0.2.2",
"minimal-grpc-server": "^0.3.1",
"neverthrow": "^4.2.2"
},
"devDependencies": {
"@types/chai": "^4.2.21",
"@types/google-protobuf": "^3.15.5",
"@types/mocha": "^9.0.0",
"@types/node": "^16.6.1",
"chai": "^4.3.4",
Expand Down
17 changes: 17 additions & 0 deletions typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//Docker Api
export { KurtosisTestsuiteDockerEnvVar, ENCLAVE_DATA_VOLUME_MOUNTPOINT } from "../src/kurtosis_testsuite_docker_api/kurtosis_testsuite_docker_api";

//RPC Api Consts
export { LISTEN_PROTOCOL, LISTEN_PORT } from "../src/kurtosis_testsuite_rpc_api_consts/kurtosis_testsuite_rpc_api_consts";

//Testsuite Files
export { TestConfigurationBuilder } from "../src/lib/testsuite/test_configuration_builder";
export { TestConfiguration } from "./lib/testsuite/test_configuration";
export { TestSuite } from "../src/lib/testsuite/test_suite";
export { Test } from "../src/lib/testsuite/test";

//Execution Files
export { MetadataProvidingTestsuiteService } from "./lib/execution/metadata_providing_testsuite_service";
export { TestExecutingTestsuiteService } from "./lib/execution/test_executing_testsuite_service";
export { TestSuiteConfigurator } from "./lib/execution/test_suite_configurator";
export { TestSuiteExecutor } from "./lib/execution/test_suite_executor";
102 changes: 51 additions & 51 deletions typescript/src/lib/execution/metadata_providing_testsuite_service.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
import { ITestSuiteServiceServer } from "../../kurtosis_testsuite_rpc_api_bindings/testsuite_service_grpc_pb";
import { TestMetadata, TestSuiteMetadata, RegisterFilesArgs, SetupTestArgs, RunTestArgs } from "../../kurtosis_testsuite_rpc_api_bindings/testsuite_service_pb";
import { TestConfigurationBuilder } from "../testsuite/test_configuration_builder"; //TODO
import { TestConfiguration } from "../testsuite/test_configuration"; //TODO
import { TestSuite } from "../testsuite/test_suite"; //TODO
import { TestConfigurationBuilder } from "../testsuite/test_configuration_builder";
import { TestConfiguration } from "../testsuite/test_configuration";
import { TestSuite } from "../testsuite/test_suite";
import { newTestMetadata } from "../constructor_calls";
import { ok, err, Result } from "neverthrow";
import * as google_protobuf_empty_pb from "google-protobuf/google/protobuf/empty_pb";
import * as grpc from "grpc";

// Service handlign endpoints when the testsuite is in metadata-providing mode - i.e. NOT running a testnet, without a connection to an API container
export class MetadataProvidingTestsuiteService implements ITestSuiteServiceServer { //TODO - right server to implement?
private readonly suite: TestSuite;

constructor(suite: TestSuite) {
this.suite = TestSuite;
}

//TODO type signature of this method in grpc bindings => isAvailable: grpc.handleUnaryCall<google_protobuf_empty_pb.Empty, google_protobuf_empty_pb.Empty>;
public isAvailable(): Result<grpc.handleUnaryCall<google_protobuf_empty_pb.Empty, google_protobuf_empty_pb.Empty>, Error> { //TODO - should I be using Result; how do I go about writing this method signature?
return ok(null);
}

public getTestSuiteMetadata(): Result<TestSuiteMetadata, Error> { //TODO - fix method signature
const allTestMetadata: Map<string, TestSuiteMetadata> = new Map();
for (let [testName, test] of this.suite.getTests().entries()) {
const testConfigBuilder: TestConfigurationBuilder = new TestConfigurationBuilder();
test.configure(testConfigBuilder);
const testConfig: TestConfiguration = testConfigBuilder.build();
const testMetadata: TestMetadata = newTestMetadata(
testConfig.isPartitioningEnabled,
testConfig.setupTimeoutSeconds,
testConfig.runTimeoutSeconds);

allTestMetadata[testName] = testMetadata;
}

const testSuiteMetadata: TestSuiteMetadata = new TestSuiteMetadata();
const testSuiteMetadataMap: Map<string, TestSuiteMetadata> = testSuiteMetadata.getTestMetadataMap();
for (let [allTestMetadataId, allTestMetadataTestSuite] of allTestMetadata.entries()) {
testSuiteMetadataMap.set(allTestMetadataId, allTestMetadataTestSuite);
}
return ok(testSuiteMetadata); //TODO - can there never be an error case?
}

public registerFiles(args: RegisterFilesArgs): Result<null, Error> { //TODO - fix method signature
return err(new Error("Received a register files call while the testsuite service is in metadata-providing mode; this is a bug in Kurtosis"));
}

public setupTest(args: SetupTestArgs): Result<null, Error> { //TODO - fix method signature
return err(new Error("Received a setup test call while the testsuite service is in metadata-providing mode; this is a bug in Kurtosis"));
}

public runTest(args: RunTestArgs): Result<null, Error> { //TODO - fix method signature
return err(new Error("Received a run test call while the testsuite service is in metadata-providing mode; this is a bug in Kurtosis"));
}
import * as jspb from "google-protobuf";
import { KnownKeysOnly } from "minimal-grpc-server";

// Service handling endpoints when the testsuite is in metadata-providing mode - i.e. NOT running a testnet, without a connection to an API container
export class MetadataProvidingTestsuiteService implements KnownKeysOnly<ITestSuiteServiceServer> {
private readonly suite: TestSuite;

constructor(suite: TestSuite) {
this.suite = suite;
}

public isAvailable(call: grpc.ServerUnaryCall<google_protobuf_empty_pb.Empty>, callback: grpc.sendUnaryData<google_protobuf_empty_pb.Empty>): void {
callback(null, null);
}

public getTestSuiteMetadata(call: grpc.ServerUnaryCall<google_protobuf_empty_pb.Empty>, callback: grpc.sendUnaryData<TestSuiteMetadata>): void {
const allTestMetadata: Map<string, TestMetadata> = new Map();
for (let [testName, test] of this.suite.getTests().entries()) {
const testConfigBuilder: TestConfigurationBuilder = new TestConfigurationBuilder();
test.configure(testConfigBuilder);
const testConfig: TestConfiguration = testConfigBuilder.build();
const testMetadata: TestMetadata = newTestMetadata(
testConfig.getIsPartitioningEnabled(),
testConfig.getSetupTimeoutSeconds(),
testConfig.getRunTimeoutSeconds());

allTestMetadata[testName] = testMetadata;
}

const testSuiteMetadata: TestSuiteMetadata = new TestSuiteMetadata();
const testSuiteMetadataMap: jspb.Map<string, TestMetadata> = testSuiteMetadata.getTestMetadataMap();
for (let [allTestMetadataId, allTestMetadataTestSuite] of allTestMetadata.entries()) {
testSuiteMetadataMap.set(allTestMetadataId, allTestMetadataTestSuite);
}
return callback(null, testSuiteMetadata);
}

public registerFiles(call: grpc.ServerUnaryCall<RegisterFilesArgs>, callback: grpc.sendUnaryData<google_protobuf_empty_pb.Empty>): void {
callback(new Error("Received a register files call while the testsuite service is in metadata-providing mode; this is a bug in Kurtosis"), null);
}

public setupTest(call: grpc.ServerUnaryCall<SetupTestArgs>, callback: grpc.sendUnaryData<google_protobuf_empty_pb.Empty>): void {
callback(new Error("Received a setup test call while the testsuite service is in metadata-providing mode; this is a bug in Kurtosis"), null);
}

public runTest(call: grpc.ServerUnaryCall<RunTestArgs>, callback: grpc.sendUnaryData<google_protobuf_empty_pb.Empty>): void{
callback(new Error("Received a run test call while the testsuite service is in metadata-providing mode; this is a bug in Kurtosis"), null);
}
}
Loading