You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/08/21 09:12:58 UTC

[GitHub] sciabarracom closed pull request #43: fixed cram tests

sciabarracom closed pull request #43: fixed cram tests
URL: https://github.com/apache/incubator-openwhisk-runtime-go/pull/43
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/test/NOTES.md b/test/NOTES.md
index 4d57316..b6ef8e1 100644
--- a/test/NOTES.md
+++ b/test/NOTES.md
@@ -17,23 +17,24 @@
 #
 -->
 
-This is an optional command line test kit.
+This is an (optional) command line test kit.
 
-It has been superseded by a go test suite and scalatests,
-but it is still around for debugging.
+There is now also go test suite and scalatests,
+but we still use it for debugging.
 
+- It works on Linux Ubuntu only (on OSX there are some differences in the CLI).
+- You need to build the images with `dockerDist`.
+- You need to install cram .
+- Test action loop: `cram test_actionloop.t`
+- Test golang `cram test_actionloop-golang.t`
 
-TO use it:
-- you need to install cram to use it and build images
-- you can run them with `cram test_actionloop.t`
-- and `cram test_actionloop-golang`
+Also you can start directly the executable, using `start.sh`  without building the images.
+So you can debug outside of Docker.
+If you start the executable  images won't be started by the test.
 
-also you can start directly the binary without the images with
+- `unset COMPILER ; ./start.sh` for action loop, then  `cram test_actionloop.t`
+- or `COMPILER=../common/gobuild.sh ./start.sh` then `cram test_actionlooop-golang.t`
 
-- `./start.sh`
-- or `COMPILER=../common/gobuild.sh ./start.sh`
-
-If you start them,  images won't be started by the test.
 
 
 
diff --git a/test/bin/build.sh b/test/bin/build.sh
index a000403..6f5c0ac 100755
--- a/test/bin/build.sh
+++ b/test/bin/build.sh
@@ -20,8 +20,10 @@ EXEC=${2:-main}
 OUT=$(basename $FILE)
 BIN=${OUT%%.go}
 ZIP=${BIN}.zip
+rm bin/$BIN
 go build -i -o bin/$BIN $FILE
 GOOS=linux GOARCH=amd64 go build -o $EXEC $FILE
+rm zip/$ZIP
 zip zip/$ZIP $EXEC
 rm $EXEC
 echo "built $EXEC bin/$BIN zip/$ZIP"
diff --git a/test/bin/init.sh b/test/bin/init.sh
index 6efc105..947146e 100755
--- a/test/bin/init.sh
+++ b/test/bin/init.sh
@@ -23,7 +23,7 @@ then MAIN=",\"main\":\"$MAIN\""
 fi
 if file -i $FILE | grep text/ >/dev/null
 then echo '{"value":{"code":' $(cat $FILE | jq -R -s .) $MAIN '}}' >$JSON
-else echo '{"value":{"binary":true,"code":"'$(base64 -w 0 $FILE)'"}}' >$JSON
+else echo '{"value":{"binary":true,"code":"'$(base64 $FILE | tr -d '\n')'"}}' >$JSON
 fi
 curl -H "Content-Type: application/json" -XPOST -w "%{http_code}\n" http://${HOST:-localhost}:${PORT:-8080}/init -d @"$JSON" 2>/dev/null
 #echo $JSON
diff --git a/test/src/hello/hello.go b/test/src/hello/hello.go
deleted file mode 100644
index 2baaa01..0000000
--- a/test/src/hello/hello.go
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package hello
-
-import (
-	"encoding/json"
-	"fmt"
-	"log"
-)
-
-// Hello receive an event in format
-// { "name": "Mike"}
-// and returns a greeting in format
-// { "greetings": "Hello, Mike"}
-func Hello(event json.RawMessage) (json.RawMessage, error) {
-	// input and output
-	var input struct {
-		Name string
-	}
-	var output struct {
-		Greetings string `json:"greetings"`
-	}
-	// read the input event
-	json.Unmarshal(event, &input)
-	if input.Name != "" {
-		// handle the event
-		output.Greetings = "Hello, " + input.Name
-		log.Println(output.Greetings)
-		return json.Marshal(output)
-	}
-	return nil, fmt.Errorf("no name specified")
-}
diff --git a/test/src/hello/hello_test.go b/test/src/hello/hello_test.go
deleted file mode 100644
index 94de222..0000000
--- a/test/src/hello/hello_test.go
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package hello
-
-import (
-	"fmt"
-)
-
-func ExampleHello() {
-	name := []byte(`{ "name": "Mike"}`)
-	data, _ := Hello(name)
-	fmt.Printf("%s", data)
-	// Output:
-	// {"greetings":"Hello, Mike"}
-}
-
-func ExampleHello_noName() {
-	name := []byte(`{ "noname": "Mike"}`)
-	_, err := Hello(name)
-	fmt.Print(err)
-	// Output:
-	// no name specified
-}
-func ExampleHello_badJson() {
-	name := []byte(`{{`)
-	_, err := Hello(name)
-	fmt.Print(err)
-	// Output:
-	// no name specified
-}
diff --git a/test/test_actionloop.t b/test/test_actionloop.t
index 4435404..fb05643 100644
--- a/test/test_actionloop.t
+++ b/test/test_actionloop.t
@@ -129,5 +129,4 @@ Test with a non-main executable
   {"error":"cannot start action: command exited"}
   400
 
-
   $ $T/stop.sh 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services