-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a542fa
commit 7909eb9
Showing
12 changed files
with
308 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
spring.application.name: "diffy" | ||
server: | ||
port: ${http.port:8888} | ||
|
||
proxy: | ||
port: 8880 | ||
|
||
candidate: "localhost:9000" | ||
|
||
master: | ||
primary: "localhost:9100" | ||
secondary: "localhost:9200" | ||
|
||
service: | ||
protocol : "http" | ||
|
||
serviceName : "Default Sample Service" | ||
|
||
allowHttpSideEffects: true | ||
|
||
spring: | ||
mongodb: | ||
embedded: | ||
version: "5.0.6" | ||
management: | ||
endpoints: | ||
web: | ||
exposure: | ||
include: health,info,prometheus | ||
|
||
logging: | ||
pattern: | ||
console: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr([diffy,%X{trace_id},%X{span_id}]) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m %n%wEx" | ||
file: "%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr([diffy,%X{trace_id},%X{span_id}]) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m %n%wEx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
(request) => { | ||
const { | ||
uri, | ||
method, | ||
path, | ||
params, | ||
headers, | ||
body | ||
} = request; | ||
|
||
const response = { | ||
status: '200 OK', | ||
headers: {}, | ||
body: { | ||
"message": "Success", | ||
"response": { | ||
"id": 98758734857, | ||
"app": 12, | ||
"resource": { | ||
"id": 150, | ||
"app": null, | ||
"label": "Test label", | ||
"hfu": { | ||
"id": 898, | ||
"app": null, | ||
"createdDate": null, | ||
"lastModifiedDate": null, | ||
"name": "test_name", | ||
"uuid": null | ||
}, | ||
"custom": false, | ||
"delhuf": false | ||
}, | ||
"title": "Test title from candidate server", | ||
"abcd": "text", | ||
"related": [ | ||
"ioi" | ||
], | ||
"data": null, | ||
"flabel": "Test", | ||
"tcon": null, | ||
"type": "UYU", | ||
"gb": [], | ||
"meas": null, | ||
"audy": null, | ||
"stpe": null, | ||
"slim": 0, | ||
"zoomInData": null, | ||
"improvement": null, | ||
"isdterange": true, | ||
"meta": null, | ||
"intcof": null, | ||
"metqu": null, | ||
"fif": { | ||
"id": null, | ||
"requestResource": null, | ||
"resource": null, | ||
"updatable": false, | ||
"empty": true | ||
}, | ||
"modified": false, | ||
"description": null, | ||
"initdat": null, | ||
"applyModifiedData": false, | ||
"sortConfiguration": null, | ||
"pasfor": null, | ||
"originalTitle": "Test original title", | ||
"uuid": "345345346", | ||
"cofn": null, | ||
"rol": null, | ||
"accessible": true, | ||
"hasDel": false, | ||
"witype": null, | ||
"empwi": false, | ||
"syd": null, | ||
"asgr": [], | ||
"ismod": false, | ||
"ughuygegg": false, | ||
"deleted": false, | ||
"newef": false, | ||
"efor": null | ||
}, | ||
"path": null | ||
} | ||
} | ||
|
||
response.body = body; | ||
return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"message": "Success", | ||
"response": { | ||
"id": 98758734857, | ||
"app": 12, | ||
"resource": { | ||
"id": 150, | ||
"app": null, | ||
"label": "Test label", | ||
"hfu": { | ||
"id": 898, | ||
"app": null, | ||
"createdDate": null, | ||
"lastModifiedDate": null, | ||
"name": "test_name", | ||
"uuid": null | ||
}, | ||
"custom": false, | ||
"delhuf": false | ||
}, | ||
"title": "Test title from candidate server", | ||
"abcd": "text", | ||
"related": [ | ||
"ioi" | ||
], | ||
"data": null, | ||
"flabel": "Test", | ||
"tcon": null, | ||
"type": "UYU", | ||
"gb": [], | ||
"meas": null, | ||
"audy": null, | ||
"stpe": null, | ||
"slim": 0, | ||
"zoomInData": null, | ||
"improvement": null, | ||
"isdterange": true, | ||
"meta": null, | ||
"intcof": null, | ||
"metqu": null, | ||
"fif": { | ||
"id": null, | ||
"requestResource": null, | ||
"resource": null, | ||
"updatable": false, | ||
"empty": true | ||
}, | ||
"modified": false, | ||
"description": null, | ||
"initdat": null, | ||
"applyModifiedData": false, | ||
"sortConfiguration": null, | ||
"pasfor": null, | ||
"originalTitle": "Test original title", | ||
"uuid": "345345346", | ||
"cofn": null, | ||
"rol": null, | ||
"accessible": true, | ||
"hasDel": false, | ||
"witype": null, | ||
"empwi": false, | ||
"syd": null, | ||
"asgr": [], | ||
"ismod": false, | ||
"ughuygegg": false, | ||
"deleted": false, | ||
"newef": false, | ||
"efor": null | ||
}, | ||
"path": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package ai.diffy; | ||
|
||
import ai.diffy.interpreter.http.HttpLambdaServer; | ||
import ai.diffy.proxy.ReactorHttpDifferenceProxy; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.core.io.FileSystemResource; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.util.FileCopyUtils; | ||
import org.springframework.web.client.RestTemplate; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
@SpringBootTest | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
public class IntegrationTest { | ||
RestTemplate restTemplate = new RestTemplate(); | ||
@Autowired | ||
Settings settings; | ||
|
||
@Autowired | ||
ReactorHttpDifferenceProxy proxy; | ||
private Integer extractPort(Downstream downstream) { | ||
HostPort hostPort = (HostPort) downstream; | ||
return hostPort.port(); | ||
} | ||
HttpLambdaServer primary, secondary, candidate; | ||
@BeforeAll | ||
public void setup() throws IOException { | ||
primary = new HttpLambdaServer(extractPort(settings.primary()), new File("src/test/resources/lambda.js")); | ||
secondary = new HttpLambdaServer(extractPort(settings.secondary()), new File("src/test/resources/lambda.js")); | ||
candidate = new HttpLambdaServer(extractPort(settings.candidate()), new File("src/test/resources/lambda.js")); | ||
} | ||
|
||
@AfterAll | ||
public void shutdown() { | ||
primary.shutdown(); | ||
secondary.shutdown(); | ||
candidate.shutdown(); | ||
} | ||
|
||
@Test | ||
public void warmup() throws Exception { | ||
String proxyUrl = "http://localhost:"+settings.servicePort()+"/base"; | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_JSON); | ||
|
||
FileSystemResource payload = new FileSystemResource("src/test/resources/payload.json"); | ||
String json = FileCopyUtils.copyToString(new InputStreamReader(payload.getInputStream())); | ||
String response = restTemplate.postForObject(proxyUrl, new HttpEntity<String>(json, headers), String.class); | ||
assertEquals(json, response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ai.diffy.compare; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.core.io.FileSystemResource; | ||
import org.springframework.util.FileCopyUtils; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
@Slf4j | ||
public class DifferenceTest { | ||
|
||
@Test | ||
public void payloadTest() throws IOException { | ||
FileSystemResource payload = new FileSystemResource("src/test/resources/payload.json"); | ||
String json = FileCopyUtils.copyToString(new InputStreamReader(payload.getInputStream())); | ||
log.info(json); | ||
Difference diff = Difference.apply(json, json); | ||
diff.flattened().foreach(tuple -> { | ||
log.info("{} - {}", tuple._1(), tuple._2()); | ||
return null; | ||
}); | ||
} | ||
} |