fsk119 commented on a change in pull request #14224:
URL: https://github.com/apache/flink/pull/14224#discussion_r532314361



##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -62,7 +62,7 @@ class IncrementMapFunction extends MapFunction[Long, Long] {
 </div>
 </div>
 
-It is very easy to unit test such a function with your favorite testing 
framework by passing suitable arguments and verifying the output.
+通过传递合适的参数并验证输出,可以很容易的使用你喜欢的测试框架对这样的函数进行单元测试。

Review comment:
       缺了主语 
   
   "的" -> "地"

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -568,20 +568,20 @@ object CollectSink {
 </div>
 </div>
 
-A few remarks on integration testing with `MiniClusterWithClientResource`:
+关于使用 `MiniClusterWithClientResource` 进行集成测试的几点备注:
 
-* In order not to copy your whole pipeline code from production to test, make 
sources and sinks pluggable in your production code and inject special test 
sources and test sinks in your tests.
+* 为了不将整个 pipeline 代码从生产复制到测试,请将 source 和 sink 插入到生产代码中,并在测试中注入特殊的测试 source 和测试 
sink。
 
-* The static variable in `CollectSink` is used here because Flink serializes 
all operators before distributing them across a cluster.
-Communicating with operators instantiated by a local Flink mini cluster via 
static variables is one way around this issue.
-Alternatively, you could write the data to files in a temporary directory with 
your test sink.
+* 这里使用 `CollectSink` 中的静态变量,是因为Flink 在将所有算子分布到整个集群之前先对其进行了序列化。
+解决此问题的一种方法是与本地 Flink 小型集群通过静态变量实例化的算子进行通信。

Review comment:
       "静态变量实例化的算子" -> "实例化算子的静态变量"
   

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -142,17 +142,17 @@ class IncrementFlatMapFunctionTest extends FlatSpec with 
MockFactory {
 </div>
 </div>
 
-### Unit Testing Stateful or Timely UDFs & Custom Operators
+### 对有状态或及时 UDF 和自定义算子进行单元测试
 
-Testing the functionality of a user-defined function, which makes use of 
managed state or timers is more difficult because it involves testing the 
interaction between the user code and Flink's runtime.
-For this Flink comes with a collection of so called test harnesses, which can 
be used to test such user-defined functions as well as custom operators:
+测试使用管理状态或定时器的用户自定义函数的功能更加困难,因为它涉及到测试用户代码和 Flink 运行时的交互。

Review comment:
       测试使用管理状态或定时器的用户自定义函数的功能更加困难 -> 对使用管理状态或定时器的用户自定义函数的功能测试会更加困难

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -177,7 +177,7 @@ To use the test harnesses a set of additional dependencies 
(test scoped) is need
 </dependency>
 {% endhighlight %}
 
-Now, the test harnesses can be used to push records and watermarks into your 
user-defined functions or custom operators, control processing time and finally 
assert on the output of the operator (including side outputs).
+现在,可以使用测试工具将记录和 watermark 推送到用户自定义函数或自定义算子中,控制处理时间,最后对算子的输出(包括旁路输出)进行断言。

Review comment:
       'assert' -> 校验

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -568,20 +568,20 @@ object CollectSink {
 </div>
 </div>
 
-A few remarks on integration testing with `MiniClusterWithClientResource`:
+关于使用 `MiniClusterWithClientResource` 进行集成测试的几点备注:
 
-* In order not to copy your whole pipeline code from production to test, make 
sources and sinks pluggable in your production code and inject special test 
sources and test sinks in your tests.
+* 为了不将整个 pipeline 代码从生产复制到测试,请将 source 和 sink 插入到生产代码中,并在测试中注入特殊的测试 source 和测试 
sink。
 
-* The static variable in `CollectSink` is used here because Flink serializes 
all operators before distributing them across a cluster.

Review comment:
       > The static variable in `CollectSink` is used here 
   
   I think it's more straightforward to illustrate which static field is used. 
Therefore, I think we'd better to modify to 
   "The static variable `values` in `CollectSink`"

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -364,7 +364,7 @@ class PassThroughProcessFunction extends 
ProcessFunction[Integer, Integer] {
 </div>
 </div>
 
-It is very easy to unit test such a function with 
`ProcessFunctionTestHarnesses` by passing suitable arguments and verifying the 
output.
+通过传递合适的参数并验证输出,对使用 `ProcessFunctionTestHarnesses` 这样的函数进行单元测试是非常容易的。

Review comment:
       通过传递合适的参数,使用`ProcessFunctionTestHarnesses` 是很容易进行单元测试并验证输出。

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -325,18 +325,18 @@ class StatefulFlatMapTest extends FlatSpec with Matchers 
with BeforeAndAfter {
 </div>
 </div>
 
-Many more examples for the usage of these test harnesses can be found in the 
Flink code base, e.g.:
+在 Flink 代码库里可以找到更多使用这些测试工具的示例,例如:
 
-* `org.apache.flink.streaming.runtime.operators.windowing.WindowOperatorTest` 
is a good example for testing operators and user-defined functions, which 
depend on processing or event time.
-* 
`org.apache.flink.streaming.api.functions.sink.filesystem.LocalStreamingFileSinkTest`
 shows how to test a custom sink with the `AbstractStreamOperatorTestHarness`. 
Specifically, it uses `AbstractStreamOperatorTestHarness.snapshot` and 
`AbstractStreamOperatorTestHarness.initializeState` to tests its interaction 
with Flink's checkpointing mechanism.
+* `org.apache.flink.streaming.runtime.operators.windowing.WindowOperatorTest` 
是测试算子和用户自定义函数(取决于处理时间和事件时间)的一个很好的例子。
+* 
`org.apache.flink.streaming.api.functions.sink.filesystem.LocalStreamingFileSinkTest`
 展示了如何使用 `AbstractStreamOperatorTestHarness` 测试自定义 sink。具体来说,它使用 
`AbstractStreamOperatorTestHarness.snapshot` 和 
`AbstractStreamOperatorTestHarness.initializeState` 来测试它与 Flink checkpoint 
机制的交互。
 
-<span class="label label-info">Note</span> Be aware that 
`AbstractStreamOperatorTestHarness` and its derived classes are currently not 
part of the public API and can be subject to change.
+<span class="label label-info">注意</span> 
请注意,`AbstractStreamOperatorTestHarness` 及其派生类目前不属于公共 API,可以进行更改。
 
-#### Unit Testing ProcessFunction
+#### 单元测试 Process Function
 
-Given its importance, in addition to the previous test harnesses that can be 
used directly to test a `ProcessFunction`, Flink provides a test harness 
factory named `ProcessFunctionTestHarnesses` that allows for easier test 
harness instantiation. Considering this example:
+考虑到它的重要性,除了之前可以直接用于测试 `ProcessFunction` 的测试工具之外,Flink 还提供了一个名为 
`ProcessFunctionTestHarnesses` 的测试工具工厂类,可以简化测试工具的实例化。考虑以下示例:
 
-<span class="label label-info">Note</span> Be aware that to use this test 
harness, you also need to introduce the dependencies mentioned in the last 
section.
+<span class="label label-info">˙注意</span> 请注意,要使用此测试工具,还需要引入上一节中介绍的依赖项。

Review comment:
       多了一个 “˙” 
   
   用两个注意看上去很重复,感觉可以去掉一个。

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -568,20 +568,20 @@ object CollectSink {
 </div>
 </div>
 
-A few remarks on integration testing with `MiniClusterWithClientResource`:
+关于使用 `MiniClusterWithClientResource` 进行集成测试的几点备注:
 
-* In order not to copy your whole pipeline code from production to test, make 
sources and sinks pluggable in your production code and inject special test 
sources and test sinks in your tests.
+* 为了不将整个 pipeline 代码从生产复制到测试,请将 source 和 sink 插入到生产代码中,并在测试中注入特殊的测试 source 和测试 
sink。

Review comment:
       "make sources and sinks pluggable in your production code" -> 让你的source 
&& sink 在生产代码中是可插拔的
   
   In test env, it's more easily to test the pipeline with the test 
source/sink, e.g DataGen && Blackhole. 

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -97,7 +97,7 @@ class IncrementMapFunctionTest extends FlatSpec with Matchers 
{
 </div>
 </div>
 
-Similarly, a user-defined function which uses an 
`org.apache.flink.util.Collector` (e.g. a `FlatMapFunction` or 
`ProcessFunction`) can be easily tested by providing a mock object instead of a 
real collector.  A `FlatMapFunction` with the same functionality as the 
`IncrementMapFunction` could be unit tested as follows.
+类似地,使用 `org.apache.flink.util.Collector` 的用户自定义函数(例如`FlatMapFunction` 或者 
`ProcessFunction`),可以通过提供模拟对象而不是真正的 collector 来轻松测试。具有与 `IncrementMapFunction` 
相同功能的 `FlatMapFunction` 可以按照以下方式进行单元测试。

Review comment:
       > 使用 `org.apache.flink.util.Collector` 的用户自定义函数
    
   加个 “对于” 在“使用”之前会更加通顺 

##########
File path: docs/dev/stream/testing.zh.md
##########
@@ -270,7 +270,7 @@ class StatefulFlatMapFunctionTest extends FlatSpec with 
Matchers with BeforeAndA
 </div>
 </div>
 
-`KeyedOneInputStreamOperatorTestHarness` and 
`KeyedTwoInputStreamOperatorTestHarness` are instantiated by additionally 
providing a `KeySelector` including `TypeInformation` for the class of the key.
+`KeyedOneInputStreamOperatorTestHarness` 和 
`KeyedTwoInputStreamOperatorTestHarness` 可以通过为键类另外提供一个包含 `TypeInformation` 的 
`KeySelector` 来实例化。

Review comment:
       把 “class of the key”  翻译成键类很奇怪,也不直观。感觉翻译成 类的键 更好一点。




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to