Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unix Stream codec, Split flow from FDK, update integration tests #150

Merged
merged 49 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
dd87c35
http input codec
zootalures Aug 29, 2018
8ab3af4
add jetty-core and UDS deps
zootalures Aug 30, 2018
348792e
PoC jetty core UDS event codec
Sep 3, 2018
d722ebb
revise FDK contract for initial relase, split flow from fn, support n…
zootalures Sep 7, 2018
08d2a4c
First pass of refactor
zootalures Sep 9, 2018
f483f85
added annotations for for features to support flow
zootalures Sep 10, 2018
e1ab94d
moving flow feature to runtime package
zootalures Sep 10, 2018
fc707dd
rename flow testing and add docs, fix race in Stream testing
zootalures Sep 10, 2018
fc9886d
fixing failing tests
zootalures Sep 10, 2018
666cb3f
Update to reflect FN_ID
zootalures Sep 11, 2018
146e83c
more integration test fixing
zootalures Sep 11, 2018
9089035
fix up format name
zootalures Sep 11, 2018
e2a3b90
first stab at home-grown UDS implementation
zootalures Sep 12, 2018
0942c6a
docker build fix
zootalures Sep 13, 2018
f478257
UDS rework, remove old UDS dep and test new one
zootalures Sep 13, 2018
f4abf59
adjust permissions on file on start
zootalures Sep 13, 2018
029f400
new integration tests
zootalures Sep 14, 2018
e5242d7
simlify build and integration tests, add tests for http-stream
zootalures Sep 14, 2018
552d5f2
fix ci
zootalures Sep 15, 2018
c941cdf
typo
zootalures Sep 15, 2018
311d58d
make igntests standalone
zootalures Sep 15, 2018
5b40435
itests run 1.8
zootalures Sep 15, 2018
0fd287d
fix itest result
zootalures Sep 15, 2018
3dbc3ee
env for itests
zootalures Sep 15, 2018
846eeb6
add createDir
zootalures Sep 15, 2018
7ddd360
test failures in circle
zootalures Sep 15, 2018
b3fa77a
fix test interference
zootalures Sep 15, 2018
64f0cbd
Use standard properties in fdk tests, fix versions in itests
zootalures Sep 15, 2018
d878986
hmm no entropy on circle boxes :)
zootalures Sep 15, 2018
561a51a
use consistent properties for versions everywhere
zootalures Sep 15, 2018
de7e460
add waits for start
zootalures Sep 15, 2018
8e2096b
this time with feeling
zootalures Sep 15, 2018
bf7248d
diagnosing timeout
zootalures Sep 16, 2018
16f6802
close input, try more aggressive testing
zootalures Sep 16, 2018
97ffadb
C errors
zootalures Sep 16, 2018
42ea541
fixing up accept and twiddling with integration test start
zootalures Sep 17, 2018
b8abc5c
set DOCKER_LOCALHOST
zootalures Sep 17, 2018
ce96bea
integration test fixing/finessing
zootalures Sep 18, 2018
ff729f2
cludge docker localhost
zootalures Sep 18, 2018
e463adb
no_proxy messing
zootalures Sep 18, 2018
e3f8d1d
set fnserver IP correctly
zootalures Sep 18, 2018
43cf9b5
typo
zootalures Sep 18, 2018
755c69d
nits in C code
zootalures Sep 18, 2018
a4bf3df
review nits
zootalures Sep 18, 2018
78d745a
more C fix nits
zootalures Sep 18, 2018
14d1b46
Make mandatory headers mandatory again
zootalures Sep 18, 2018
e2209d7
minus comment
zootalures Sep 18, 2018
fef06de
remove Content-Length from stripped input
zootalures Sep 18, 2018
df25e51
fix call test
zootalures Sep 18, 2018
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
2 changes: 1 addition & 1 deletion examples/async-thumbnails/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
2 changes: 1 addition & 1 deletion examples/qr-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
2 changes: 1 addition & 1 deletion examples/regex-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
2 changes: 1 addition & 1 deletion examples/string-reverse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ They should _not_ be used for:
```bash
export REPOSITORY_LOCATION=/tmp/staging-repository
# on OSX:
export DOCKER_LOCALHOST=docker.for.mac.localhost
export DOCKER_LOCALHOST=docker.for.mac.host.internal

mvn deploy -DaltDeploymentRepository=localStagingDir::default::file://"$REPOSITORY_LOCATION"
```
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/funcs/flowAllFeatures/func.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
schema_version: 20180708
name: test
name: flowallfeatures
version: 0.0.15
runtime: java
cmd: com.fnproject.fn.integration.ExerciseEverything::handleRequest
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/funcs/flowBasic/func.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
schema_version: 20180708
name: test
name: flowbasic
version: 0.0.7
runtime: java
cmd: com.fnproject.fn.integration.test_1.CompleterFunction::handleRequest
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/funcs/flowBasicJDK8/func.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
schema_version: 20180708
name: test
name: flowbasicj8
version: 0.0.3
runtime: java8
cmd: com.fnproject.fn.integration.test_1.CompleterFunction::handleRequest
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/funcs/flowExitHooks/func.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
schema_version: 20180708
name: test
name: flowexithooks
version: 0.0.3
runtime: java9
cmd: com.fnproject.fn.integration.test_5.CompleterFunction::handleRequest
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/funcs/flowTimeouts/func.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
schema_version: 20180708
name: test
name: flowtimeouts
version: 0.0.3
runtime: java9
cmd: com.fnproject.fn.integration.test_6.CompleterFunction::handleRequest
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/funcs/simpleFunc/func.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
schema_version: 20180708
name: test
name: simplefunc
version: 0.0.3
runtime: java9
cmd: com.fnproject.fn.integration.test2.PlainFunction::handleRequest
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
Expand Down
19 changes: 15 additions & 4 deletions integration-tests/run_tests_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ until $(curl --output /dev/null --silent --fail http://localhost:18080); do
sleep 1
done

MAVEN_REPOSITORY="http://$(docker inspect --type container -f '{{.NetworkSettings.IPAddress}}' fn_mvn_repo):18080"
export MAVEN_REPOSITORY

# Start Fn
fn stop || true
Expand All @@ -41,8 +39,6 @@ done
export FN_LOG_FILE=/tmp/fn.log
docker logs -f fnserver >& ${FN_LOG_FILE} &

DOCKER_LOCALHOST=$(docker inspect --type container -f '{{.NetworkSettings.IPAddress}}' fnserver)
export DOCKER_LOCALHOST

docker rm -f flowserver || true
docker run --rm -d \
Expand All @@ -61,6 +57,21 @@ export FLOW_LOG_FILE=/tmp/flow.log
docker logs -f flowserver >& ${FLOW_LOG_FILE} &
set +e


DOCKER_LOCALHOST= docker.for.mac.host.internal # $(docker inspect --type container -f '{{.NetworkSettings.IPAddress}}' fnserver)
export DOCKER_LOCALHOST

REPO_IP=$(docker inspect --type container -f '{{.NetworkSettings.IPAddress}}' fn_mvn_repo)
MAVEN_REPOSITORY="http://${REPO_IP}:18080"
export MAVEN_REPOSITORY
COMPLETER_IP=$(docker inspect --type container -f '{{.NetworkSettings.IPAddress}}' flowserver)
COMPLETER_BASE_URL="http://${COMPLETER_IP}:8081"
export COMPLETER_BASE_URL

export no_proxy=$no_proxy,$DOCKER_LOCALHOST,$COMPLETER_IP,$REPO_IP



echo "ENV: "
env
echo "Running tests"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -58,7 +55,7 @@ public String getDockerLocalhost() {
String osName = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);

if (osName.contains("darwin") || osName.contains("mac")) {
return "docker.for.mac.localhost";
return "docker.for.mac.host.internal";
} else
throw new RuntimeException("Unable to determine docker localhost address - set 'DOCKER_LOCALHOST' env variable to the docker host network address ");
}
Expand Down Expand Up @@ -152,7 +149,7 @@ public TestContext withDirFrom(String location) throws IOException {
}

public CmdResult runFnWithInput(String input, String... args) throws Exception {
CmdResult res = runFnWithInputAllowError(input,args);
CmdResult res = runFnWithInputAllowError(input, args);

Assertions.assertThat(res.isSuccess()).withFailMessage("Expected command '" + res.cmd + "' to return 0").isTrue();
return res;
Expand All @@ -179,8 +176,10 @@ public CmdResult runFnWithInputAllowError(String input, String... args) throws E
// this means that FN init will pick up the local version not the latest.
pb.environment().put("FN_JAVA_FDK_VERSION", "1.0.0-SNAPSHOT");
}
pb.environment().put("no_proxy", getDockerLocalhost());
pb.environment().put("NO_PROXY", getDockerLocalhost());

// Sort of a hack for local mac running with a prioxy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

String noProxy = Optional.ofNullable(System.getenv("no_proxy")).map((f) -> f + ",").orElse("") + getDockerLocalhost();
pb.environment().put("no_proxy", noProxy);

Process p = pb.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void shouldInvokeBasicFlow() throws Exception {
tc.withDirFrom("funcs/flowBasic").rewritePOM();
tc.runFn("--verbose", "deploy", "--app", tc.appName(), "--local");
tc.runFn("config", "app", tc.appName(), "COMPLETER_BASE_URL", testRule.getFlowURL());
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "test");
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "flowbasic");
assertThat(r.getStdout()).isEqualTo("4");
}

Expand All @@ -39,7 +39,7 @@ public void shouldInvokeBasicFlowJDK8() throws Exception {
tc.withDirFrom("funcs/flowBasicJDK8").rewritePOM();
tc.runFn("--verbose", "deploy", "--app", tc.appName(), "--local");
tc.runFn("config", "app", tc.appName(), "COMPLETER_BASE_URL", testRule.getFlowURL());
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "test");
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "flowbasicj8");
assertThat(r.getStdout()).isEqualTo("4");
}

Expand All @@ -50,7 +50,7 @@ public void shouldExerciseAllFlow() throws Exception {
tc.withDirFrom("funcs/flowAllFeatures").rewritePOM();
tc.runFn("--verbose", "deploy", "--app", tc.appName(), "--local");
tc.runFn("config", "app", tc.appName(), "COMPLETER_BASE_URL", testRule.getFlowURL());
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "test");
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "flowallfeatures");
assertThat(r.getStdout()).contains("Everything worked");
}

Expand All @@ -72,10 +72,12 @@ public void shouldCallExitHooks() throws Exception {
try {
IntegrationTestRule.TestContext tc = testRule.newTest();
tc.withDirFrom("funcs/flowExitHooks").rewritePOM();
tc.runFn("--verbose", "build", "--no-cache");

tc.runFn("--verbose", "deploy", "--app", tc.appName(), "--local");
tc.runFn("config", "app", tc.appName(), "COMPLETER_BASE_URL", testRule.getFlowURL());
tc.runFn("config", "app", tc.appName(), "TERMINATION_HOOK_URL", "http://" + testRule.getDockerLocalhost() + ":" + 8000 + "/exited");
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "test");
CmdResult r = tc.runFnWithInput("1", "invoke", tc.appName(), "flowexithooks");
assertThat(r.getStdout()).contains("42");

assertThat(done.get(10, TimeUnit.SECONDS)).withFailMessage("Expected callback within 10 seconds").isTrue();
Expand All @@ -92,7 +94,7 @@ public void shouldHandleTimeouts() throws Exception {
tc.withDirFrom("funcs/flowTimeouts").rewritePOM();
tc.runFn("--verbose", "deploy", "--app", tc.appName(), "--local");
tc.runFn("config", "app", tc.appName(), "COMPLETER_BASE_URL", testRule.getFlowURL());
CmdResult r = tc.runFn("invoke", tc.appName(), "test");
CmdResult r = tc.runFn("invoke", tc.appName(), "flowtimeouts");
assertThat(r.getStdout()).contains("timeout");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public void shouldCallExistingFn() throws Exception {
tc.runFn("config", "app", tc.appName(), "GREETING", "Salutations");


CmdResult r1 = tc.runFnWithInput("", "invoke", tc.appName(), "test");
CmdResult r1 = tc.runFnWithInput("", "invoke", tc.appName(), "simplefunc");
assertThat(r1.getStdout()).isEqualTo("Salutations, world!");


CmdResult r2 = tc.runFnWithInput("tests", "invoke", tc.appName(), "test");
CmdResult r2 = tc.runFnWithInput("tests", "invoke", tc.appName(), "simplefunc");
assertThat(r2.getStdout()).isEqualTo("Salutations, tests!");

}
Expand All @@ -40,10 +40,12 @@ public void checkBoilerPlate() throws Exception {
for (String format : new String[]{"default", "http", "http-stream"}) {
for (String runtime : new String[]{"java9", "java8"}) {
IntegrationTestRule.TestContext tc = testRule.newTest();
tc.runFn("init", "--runtime", runtime, "--name", "test", "--trigger", "none", "--format", format);
String fnName = "bp" + format + runtime;

tc.runFn("init", "--runtime", runtime, "--name", fnName,"--format", format);
tc.rewritePOM();
tc.runFn("--verbose", "deploy", "--app", tc.appName(), "--local");
CmdResult rs = tc.runFnWithInput("wibble", "invoke", tc.appName(), "test");
CmdResult rs = tc.runFnWithInput("wibble", "invoke", tc.appName(), fnName);
assertThat(rs.getStdout()).contains("Hello, wibble!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public HTTPStreamCodec(Map<String, String> env) {
String listenerAddress = getRequiredEnv("FN_LISTENER");

if (!listenerAddress.startsWith("unix:/")) {
throw new FunctionInitializationException("Invalid listener address - it should start with unix:/" + listenerAddress);
throw new FunctionInitializationException("Invalid listener address - it should start with unix:/ :'" + listenerAddress +"'");
}
String listenerFile = listenerAddress.substring("unix:".length());

Expand Down