AydarZaynutdinov commented on a change in pull request #16138:
URL: https://github.com/apache/beam/pull/16138#discussion_r764652499



##########
File path: playground/backend/cmd/server/server.go
##########
@@ -107,8 +108,13 @@ func setupCache(ctx context.Context, appEnv 
environment.ApplicationEnvs) (cache.
 }
 
 func main() {
+       os.Setenv("PROTOCOL_TYPE", "TCP")
        err := runServer()
        if err != nil {
                panic(err)
        }
 }
+
+// "// Licensed to the Apache Software Foundation (ASF) under one or more\n// 
contributor license agreements.  See the NOTICE file distributed with\n// this 
work for additional information regarding copyright ownership.\n// The ASF 
licenses this file to You under the Apache License, Version 2.0\n// (the 
\"License\"); you may not use this file except in compliance with\n// the 
License.  You may obtain a copy of the License at\n//\n//    
http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by 
applicable law or agreed to in writing, software\n// distributed under the 
License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the 
specific language governing permissions and\n// limitations under the 
License.\n\npackage beam_test\n\nimport 
(\n\t\"fmt\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam\"\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/
 
passert\"\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/testing/ptest\"\n\t\"github.com/golang/protobuf/proto\"\n)\n\ntype
 wc struct {\n\tK string\n\tV int\n}\n\nfunc TestCreate(t *testing.T) 
{\n\ttests := []struct {\n\t\tvalues []interface{}\n\t}{\n\t\t{[]interface{}{1, 
2, 3}},\n\t\t{[]interface{}{\"1\", \"2\", 
\"3\"}},\n\t\t{[]interface{}{float32(0.1), float32(0.2), 
float32(0.3)}},\n\t\t{[]interface{}{float64(0.1), float64(0.2), 
float64(0.3)}},\n\t\t{[]interface{}{uint(1), uint(2), 
uint(3)}},\n\t\t{[]interface{}{false, true, true, false, 
true}},\n\t\t{[]interface{}{wc{\"a\", 23}, wc{\"b\", 42}, wc{\"c\", 
5}}},\n\t\t{[]interface{}{&testProto{}, &testProto{stringValue(\"test\")}}}, // 
Test for BEAM-4401\n\t}\n\n\tfor _, test := range tests {\n\t\tp, s := 
beam.NewPipelineWithRoot()\n\t\tc := beam.Create(s, 
test.values...)\n\t\tpassert.Equals(s, c, test.values...)\n\n\t\tif err := 
ptest.Run(p); err != nil {\n\t\t\tt.Errorf(\"beam.Create(%v) failed: %v\", 
test.values, err)\n\t\t}\n\t
 }\n}\n\nfunc TestCreateList(t *testing.T) {\n\ttests := []struct {\n\t\tvalues 
interface{}\n\t}{\n\t\t{[]int{1, 2, 3}},\n\t\t{[]string{\"1\", \"2\", 
\"3\"}},\n\t\t{[]float32{float32(0.1), float32(0.2), 
float32(0.3)}},\n\t\t{[]float64{float64(0.1), float64(0.2), 
float64(0.3)}},\n\t\t{[]uint{uint(1), uint(2), uint(3)}},\n\t\t{[]bool{false, 
true, true, false, true}},\n\t\t{[]wc{wc{\"a\", 23}, wc{\"b\", 42}, wc{\"c\", 
5}}},\n\t\t{[]*testProto{&testProto{}, &testProto{stringValue(\"test\")}}}, // 
Test for BEAM-4401\n\t}\n\n\tfor _, test := range tests {\n\t\tp, s := 
beam.NewPipelineWithRoot()\n\t\tc := beam.CreateList(s, test.values)\n\n\t\tvar 
values []interface{}\n\t\tv := reflect.ValueOf(test.values)\n\t\tfor i := 0; i 
< v.Len(); i++ {\n\t\t\tvalues = append(values, 
v.Index(i).Interface())\n\t\t}\n\t\tpassert.Equals(s, c, values...)\n\n\t\tif 
err := ptest.Run(p); err != nil {\n\t\t\tt.Errorf(\"beam.CreateList(%v) failed: 
%v\", test.values, err)\n\t\t}\n\t}\n}\n\nfunc TestCreateEmptyLi
 st(t *testing.T) {\n\ttests := []struct {\n\t\tvalues 
interface{}\n\t}{\n\t\t{[]int{}},\n\t\t{[]string{}},\n\t\t{[]float32{}},\n\t\t{[]float64{}},\n\t\t{[]uint{}},\n\t\t{[]bool{}},\n\t\t{[]wc{}},\n\t\t{[]*testProto{}},
 // Test for BEAM-4401\n\t}\n\n\tfor _, test := range tests {\n\t\tp, s := 
beam.NewPipelineWithRoot()\n\t\tc := beam.CreateList(s, 
test.values)\n\n\t\tpassert.Empty(s, c)\n\n\t\tif err := ptest.Run(p); err != 
nil {\n\t\t\tt.Errorf(\"beam.CreateList(%v) failed: %v\", test.values, 
err)\n\t\t}\n\t}\n}\n\ntype testProto struct {\n\t// OneOfField is an 
interface-typed field and cannot be JSON-marshaled, but\n\t// should be 
specially handled by Beam as a field of a proto.Message.\n\tOneOfField 
_isOneOfField\n}\n\ntype stringValue string\n\nfunc (stringValue) 
isOneOfField() {}\n\ntype _isOneOfField interface 
{\n\tisOneOfField()\n}\n\nfunc (t *testProto) Reset()         { *t = 
testProto{} }\nfunc (t *testProto) String() string { return 
fmt.Sprintf(\"one_of_field: %#v\", t.OneO
 fField) }\nfunc (t *testProto) ProtoMessage()  {}\n\nfunc (t *testProto) 
Marshal() ([]byte, error) {\n\tif t.OneOfField == nil {\n\t\treturn nil, 
nil\n\t}\n\treturn []byte(t.OneOfField.(stringValue)), nil\n}\nfunc (t 
*testProto) Unmarshal(b []byte) error {\n\tif len(b) == 0 {\n\t\treturn 
nil\n\t}\n\tt.OneOfField = stringValue(b)\n\treturn nil\n}\n\n// Ensure 
testProto is detected as a proto.Message and can be (un)marshalled by\n// the 
proto library.\nvar (\n\t_ proto.Message     = &testProto{}\n\t_ 
proto.Marshaler   = &testProto{}\n\t_ proto.Unmarshaler = &testProto{}\n)\n"
+// "// Licensed to the Apache Software Foundation (ASF) under one or more\n// 
contributor license agreements.  See the NOTICE file distributed with\n// this 
work for additional information regarding copyright ownership.\n// The ASF 
licenses this file to You under the Apache License, Version 2.0\n// (the 
\"License\"); you may not use this file except in compliance with\n// the 
License.  You may obtain a copy of the License at\n//\n//    
http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by 
applicable law or agreed to in writing, software\n// distributed under the 
License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the 
specific language governing permissions and\n// limitations under the 
License.\n\npackage beam\n\nimport 
(\n\t\"bytes\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/core/runtime/graphx/schema\"\n)\n\nfunc
 TestJSONCo
 der(t *testing.T) {\n\tv := \"teststring\"\n\ttests := 
[]interface{}{\n\t\t43,\n\t\t12431235,\n\t\t-2,\n\t\t0,\n\t\t1,\n\t\ttrue,\n\t\t\"a
 string\",\n\t\tmap[int64]string{1: \"one\", 11: \"oneone\", 21: \"twoone\", 
1211: \"onetwooneone\"},\n\t\tstruct {\n\t\t\tA int\n\t\t\tB *string\n\t\t\tC 
bool\n\t\t}{4, &v, false},\n\t}\n\n\tfor _, test := range tests {\n\t\tvar 
results []string\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tdata, err := 
jsonEnc(test)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Failed to encode %v: 
%v\", test, err)\n\t\t\t}\n\t\t\tresults = append(results, 
string(data))\n\t\t}\n\t\tfor i, data := range results {\n\t\t\tif data != 
results[0] {\n\t\t\t\tt.Errorf(\"coder not deterministic: data[%d]: %v != %v 
\", i, data, results[0])\n\t\t\t}\n\t\t}\n\n\t\tdecoded, err := 
jsonDec(reflect.TypeOf(test), []byte(results[0]))\n\t\tif err != nil 
{\n\t\t\tt.Fatalf(\"Failed to decode: %v\", err)\n\t\t}\n\n\t\tif 
!reflect.DeepEqual(decoded, test) {\n\t\t\tt.Errorf(\"Corrupt coding: %v,
  want %v\", decoded, test)\n\t\t}\n\t}\n}\n\nfunc TestSchemaCoder(t 
*testing.T) {\n\tv := \"teststring\"\n\ttests := []interface{}{\n\t\tstruct 
{\n\t\t\tA int\n\t\t\tB *string\n\t\t\tC bool\n\t\t}{4, &v, 
false},\n\t\t&struct {\n\t\t\tA int\n\t\t\tB *string\n\t\t\tC bool\n\t\t}{4, 
&v, false},\n\t\tstruct {\n\t\t\tA map[string]int\n\t\t\tB 
[]int\n\t\t}{map[string]int{\"three\": 3}, []int{4}},\n\t\tstruct {\n\t\t\tA 
map[string]int\n\t\t\tB [1]int\n\t\t}{map[string]int{\"three\": 3}, 
[...]int{4}},\n\t}\n\n\tfor _, test := range tests {\n\t\trt := 
reflect.TypeOf(test)\n\t\tt.Run(fmt.Sprintf(\"%v\", rt), func(t *testing.T) 
{\n\t\t\tvar results []string\n\t\t\tfor i := 0; i < 10; i++ {\n\t\t\t\tdata, 
err := schemaEnc(rt, test)\n\t\t\t\tif err != nil 
{\n\t\t\t\t\tt.Fatalf(\"Failed to encode %v: %v\", test, 
err)\n\t\t\t\t}\n\t\t\t\tresults = append(results, 
string(data))\n\t\t\t}\n\t\t\tfor i, data := range results {\n\t\t\t\tif data 
!= results[0] {\n\t\t\t\t\tt.Errorf(\"coder not determinis
 tic: data[%d]: %v != %v \", i, data, 
results[0])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdecoded, err := schemaDec(rt, 
[]byte(results[0]))\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Failed to 
decode: %v\", err)\n\t\t\t}\n\n\t\t\tif !reflect.DeepEqual(decoded, test) 
{\n\t\t\t\tt.Errorf(\"Corrupt coding: %v, want %v\", decoded, 
test)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestCoders(t *testing.T) {\n\tptrString 
:= \"test *string\"\n\ttype regTestType struct {\n\t\tA 
[4]int\n\t}\n\tschema.RegisterType(reflect.TypeOf((*regTestType)(nil)))\n\ttests
 := 
[]interface{}{\n\t\t43,\n\t\t12431235,\n\t\t-2,\n\t\t0,\n\t\t1,\n\t\ttrue,\n\t\t\"a
 string\",\n\t\tmap[int64]string{1: \"one\", 11: \"oneone\", 21: \"twoone\", 
1211: \"onetwooneone\"}, // (not supported by custom type 
registration)\n\t\tstruct {\n\t\t\tA int\n\t\t\tB *string\n\t\t\tC 
bool\n\t\t}{4, &ptrString, false},\n\t\t[...]int64{1, 2, 3, 4, 5}, // array 
(not supported by custom type registration)\n\t\t[]int64{1, 2, 3, 4, 5},    // 
slice\n\t\tstruct {\n
 \t\t\tA []int\n\t\t\tB [3]int\n\t\t}{A: []int{1, 2, 3}, B: [...]int{4, 5, 
6}},\n\t\t[...]struct{ A int }{{1}, {2}, {3}, {4}, {5}},\n\t\t[]struct{ B int 
}{{1}, {2}, {3}, {4}, {5}},\n\t\tregTestType{[4]int{4, 2, 4, 2}},\n\t}\n\n\tfor 
_, test := range tests {\n\t\tt.Run(fmt.Sprintf(\"%T\", test), func(t 
*testing.T) {\n\t\t\tvar results []string\n\t\t\trt := 
reflect.TypeOf(test)\n\t\t\tenc := NewElementEncoder(rt)\n\t\t\tfor i := 0; i < 
10; i++ {\n\t\t\t\tvar buf bytes.Buffer\n\t\t\t\tif err := enc.Encode(test, 
&buf); err != nil {\n\t\t\t\t\tt.Fatalf(\"Failed to encode %v: %v\", test, 
err)\n\t\t\t\t}\n\t\t\t\tresults = append(results, 
string(buf.Bytes()))\n\t\t\t}\n\t\t\tfor i, d := range results {\n\t\t\t\tif d 
!= results[0] {\n\t\t\t\t\tt.Errorf(\"coder not deterministic: encoding %d not 
the same as the first encoding: %v != %v \", i, d, 
results[0])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdec := 
NewElementDecoder(rt)\n\t\t\tbuf := 
bytes.NewBuffer([]byte(results[0]))\n\t\t\tdecoded, err := dec.De
 code(buf)\n\t\t\tif err != nil {\n\t\t\t\tt.Fatalf(\"Failed to decode: %q, 
%v\", results[0], err)\n\t\t\t}\n\n\t\t\tif !reflect.DeepEqual(decoded, test) 
{\n\t\t\t\tt.Errorf(\"Corrupt coding: %v, want %v\", decoded, 
test)\n\t\t\t}\n\t\t})\n\t}\n}\n"
+// "// Licensed to the Apache Software Foundation (ASF) under one or more\n// 
contributor license agreements.  See the NOTICE file distributed with\n// this 
work for additional information regarding copyright ownership.\n// The ASF 
licenses this file to You under the Apache License, Version 2.0\n// (the 
\"License\"); you may not use this file except in compliance with\n// the 
License.  You may obtain a copy of the License at\n//\n//    
http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by 
applicable law or agreed to in writing, software\n// distributed under the 
License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the 
specific language governing permissions and\n// limitations under the 
License.\n\npackage beam_test\n\nimport 
(\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam\"\n)\n\n//
 foolFn is a no-op CombineFn.\ntype foolFn struct {\n\tOutp
 utType beam.EncodedType\n}\n\ntype foolAccum struct{}\n\nfunc (f *foolFn) 
CreateAccumulator() *foolAccum {\n\treturn &foolAccum{}\n}\n\nfunc (f *foolFn) 
AddInput(a *foolAccum, v beam.U) *foolAccum {\n\treturn a\n}\n\nfunc (f 
*foolFn) MergeAccumulators(a *foolAccum, b *foolAccum) *foolAccum {\n\treturn 
a\n}\n\nfunc (f *foolFn) ExtractOutput(a *foolAccum) beam.V {\n\treturn 
reflect.New(f.OutputType.T).Elem().Interface()\n}\n\nfunc 
TestCombineWithTypeDefinition(t *testing.T) {\n\t_, s := 
beam.NewPipelineWithRoot()\n\tin := beam.Create(s, 1, 2, 3)\n\tstrType := 
reflect.TypeOf(\"\")\n\tcombineFn := &foolFn{OutputType: beam.EncodedType{T: 
strType}}\n\toutput := beam.Combine(s, combineFn, in, beam.TypeDefinition{Var: 
beam.VType, T: strType})\n\tif output.Type().Type() != strType 
{\n\t\tt.Errorf(\"expect combine output type to be %v, got %v\", strType, 
output.Type().Type())\n\t}\n}\n"

Review comment:
       It seems that we do not need this one. 

##########
File path: playground/backend/containers/go/Dockerfile
##########
@@ -56,6 +56,14 @@ ENV BEAM_SDK="SDK_GO"
 ## Copy build result
 COPY src/configs /opt/playground/backend/configs/
 
+# Temp - create grpcox
+# Update aptitude with new repo
+RUN apt-get update
+# Install software
+RUN apt-get install -y git
+WORKDIR /opt
+RUN git clone https://github.com/gusaul/grpcox.git

Review comment:
       Why do we need this one?

##########
File path: playground/backend/internal/executors/executor_test.go
##########
@@ -51,7 +51,10 @@ func BaseExecutorBuilder(envs environment.BeamEnvs, 
workingDir string, filePath
        }
        builder := NewExecutorBuilder().
                WithExecutableFileName("HelloWorld").
-               WithWorkingDir(workingDir).
+               WithWorkingDir(workingDir).WithValidator().

Review comment:
       ```suggestion
                WithWorkingDir(workingDir).
                WithValidator().
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to