Skip to content

Commit

Permalink
feat(GrpcService): add app name field in proto to configure histCfg (#…
Browse files Browse the repository at this point in the history
…149)

* feat(GrpcService): add app name field in proto to configure histCfg

Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com>

* refactor: use generic way for all os

Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com>

* docs: update sdk version in readme

Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com>

---------

Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com>
  • Loading branch information
Sarthak160 authored Apr 23, 2023
1 parent 8a9760b commit 8218d75
Show file tree
Hide file tree
Showing 4 changed files with 986 additions and 138 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ Add *keploy-sdk* as a dependency to your *pom.xml*:
<dependency>
<groupId>io.keploy</groupId>
<artifactId>keploy-sdk</artifactId>
<version>N.N.N</version> (eg: 1.2.8)
<version>N.N.N</version> (eg: 1.2.9)
</dependency>

or to *build.gradle*:

implementation 'io.keploy:keploy-sdk:N.N.N' (eg: 1.2.8)
implementation 'io.keploy:keploy-sdk:N.N.N' (eg: 1.2.9)

### KEPLOY_MODE

Expand Down Expand Up @@ -85,10 +85,10 @@ There are 3 modes:
- **Run along with agent to mock external calls of your API 🤩🔥**

- Download the latest - Download the latest agent jar
from [here](https://repo1.maven.org/maven2/io/keploy/agent/1.2.8/) (eg: 1.2.8)
from [here](https://repo1.maven.org/maven2/io/keploy/agent/1.2.9/) (eg: 1.2.9)

- Prefix `-javaagent:` with absolute classpath of agent jar (
eg: `-javaagent:<your full path to agent jar>/agent-1.2.8.jar`).
eg: `-javaagent:<your full path to agent jar>/agent-1.2.9.jar`).

1. **Using Intellij:** Go to Edit Configuration-> add VM options -> paste _java agent_ edited above.

Expand Down Expand Up @@ -126,7 +126,7 @@ There are 3 modes:
</plugin>
```
- And then run this
command:`java -javaagent:<your full path to agent jar>/agent-1.2.8.jar -jar <your full path to application jar>.jar`
command:`java -javaagent:<your full path to agent jar>/agent-1.2.9.jar -jar <your full path to application jar>.jar`
. This command will attach agent jar and also run the application. You need to set some required env
variables written below in order to generate test cases. So, run this command after setting the env
variables.
Expand Down
8 changes: 6 additions & 2 deletions api/src/main/java/io/keploy/service/GrpcService.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class GrpcService {
private static final String SET_PLAIN_TEXT = "\033[0;0m";

private static final String SET_BOLD_TEXT = "\033[0;1m";
public static String AppPath = "";

/**
* Initialising GRPC server ang Keploy instance
Expand All @@ -66,11 +67,12 @@ public GrpcService() {
.usePlaintext()
.build();
blockingStub = RegressionServiceGrpc.newBlockingStub(channel);

AppPath = System.getProperty("user.dir");
}

/**
* Get the url to connect to the server
*
* @return String which contains host and port of the server
*/
private String getTarget() {
Expand Down Expand Up @@ -120,7 +122,7 @@ public static void CaptureTestCases(String reqBody, Map<String, String> params,
httpReqBuilder.setProtoMajor(Character.getNumericValue(protocolType.charAt(protocolType.length() - 3)));
httpReqBuilder.setProtoMinor(Character.getNumericValue(protocolType.charAt(protocolType.length() - 1)));

testCaseReqBuilder.setAppID(k.getCfg().getApp().getName());
testCaseReqBuilder.setAppID(k.getCfg().getApp().getName()).setAppPath(AppPath);
testCaseReqBuilder.setCaptured(Instant.now().getEpochSecond());

/*
Expand Down Expand Up @@ -166,6 +168,7 @@ public static void Capture(Service.TestCaseReq.Builder testCaseReqBuilder, Map<S

/**
* This method sends the testcases to the server
*
* @param testCaseReq - test case object
*/
public static void put(Service.TestCaseReq testCaseReq) {
Expand Down Expand Up @@ -678,6 +681,7 @@ public static String start(String total) {
.setApp(k.getCfg().getApp().getName())
.setTestCasePath(k.getCfg().getApp().getTestPath())
.setMockPath(k.getCfg().getApp().getMockPath())
.setAppPath(AppPath)
.setTotal(total).build();

Service.startResponse startResponse = null;
Expand Down
5 changes: 5 additions & 0 deletions models/src/main/java/io/keploy/grpc/proto/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ message TestCaseReq {
string Type = 12;
GrpcReq GrpcReq = 13;
GrpcResp GrpcResp = 14;
string AppPath = 15;
}


Expand Down Expand Up @@ -58,6 +59,9 @@ message TestCase {
map<string, StrArr> anchors = 12;
repeated string noise = 13;
repeated Mock Mocks = 14;
GrpcReq GrpcReq = 15;
GrpcResp GrpcResp = 16;
string Type = 17;
}

message Method {
Expand Down Expand Up @@ -112,6 +116,7 @@ message startRequest {
string app = 2;
string TestCasePath = 3;
string MockPath = 4;
string AppPath = 5;
}

message startResponse {
Expand Down
Loading

0 comments on commit 8218d75

Please sign in to comment.