You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/08/22 19:27:27 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #22344: [BEAM-13004] DebeziumIO Load Test

damccorm commented on code in PR #22344:
URL: https://github.com/apache/beam/pull/22344#discussion_r951825957


##########
.test-infra/kubernetes/postgres/postgres-service-for-debezium.yml:
##########
@@ -0,0 +1,59 @@
+#    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.
+
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: postgres-for-dev
+  labels:
+    name: postgres
+spec:
+  ports:
+    - port: 5432
+  selector:
+    name: postgres
+  type: LoadBalancer
+
+---
+
+apiVersion: v1
+kind: ReplicationController
+metadata:
+  name: postgres
+spec:
+  replicas: 1
+  selector:
+    name: postgres
+  template:
+    metadata:
+      name: postgres
+      labels:
+        name: postgres
+    spec:
+      containers:
+        - name: postgres
+          image: postgres
+          args: ["-c", "wal_level=logical","-c","max_wal_senders=4","-c","max_replication_slots=4"]
+          
+        
+          env:

Review Comment:
   Nit - weird spacing here



##########
.test-infra/kubernetes/postgres/postgres-service-for-debezium.yml:
##########
@@ -0,0 +1,59 @@
+#    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.
+
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: postgres-for-dev

Review Comment:
   ```suggestion
     name: postgres-for-debezium
   ```



##########
.test-infra/jenkins/job_PerformanceTests_Debezium.groovy:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+import CommonJobProperties as common
+import Kubernetes
+import InfluxDBCredentialsHelper
+import LoadTestsBuilder
+
+String jobName = "beam_PerformanceTests_Debezium"
+
+String kubernetesYmlPath = "src/.test-infra/kubernetes/postgres/postgres-service-for-debezium.yml"
+
+
+String task = ":sdks:python:apache_beam:testing:load_tests:run -PloadTest.mainClass=apache_beam.testing.load_tests.debezium_performance_test -Prunner=DirectRunner"

Review Comment:
   Do we really want to be running this on the direct runner? That seems unusual?



##########
sdks/python/apache_beam/testing/load_tests/debezium_performance_test.py:
##########
@@ -0,0 +1,170 @@
+#
+# 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.
+#
+
+"""
+Performance test for debezium.
+
+The purpose of this test is verify that Python's connector ReadFromDebezium
+work propertly, for this, the test create a postgresql database inside a
+kubernetes pod and stream querys inside of the database for 20 minutes.
+After that ReadFromDebezium checks if everything goes well
+
+Example test run:
+
+python -m apache_beam.testing.load_tests.debezium_performance
+
+or:
+
+./gradlew
+ -PloadTest.mainClass=apache_beam.testing.load_tests.debezium_performance \
+-Prunner=DirectRunner :sdks:python:apache_beam:testing:load_tests:run
+"""
+
+import logging
+import random
+import time
+from concurrent.futures import ThreadPoolExecutor
+
+import psycopg2
+
+from apache_beam.io.debezium import DriverClassName
+from apache_beam.io.debezium import ReadFromDebezium
+from apache_beam.testing.load_tests.load_test import LoadTest
+
+
+class DebeziumLoadTest(LoadTest):
+  def __init__(self):
+    super().__init__()
+    self.kubernetes_host = self.pipeline.get_option('kubernetes_host')
+    self.kubernetes_port = self.pipeline.get_option('kubernetes_port')
+    self.postgres_user = self.pipeline.get_option('postgres_user')
+    self.postgres_password = self.pipeline.get_option('postgres_password')
+
+    self.username = self.postgres_user
+    self.password = self.postgres_password
+
+    self.database = 'postgres'
+    self.port = self.kubernetes_port
+    self.host = self.kubernetes_host
+    self.connector_class = DriverClassName.POSTGRESQL
+    self.connection_properties = [
+        "database.dbname=postgres",
+        "database.server.name=postgres",
+        "database.include.list=postgres",
+        "include.schema.changes=false",
+        "plugin.name=pgoutput"
+    ]
+
+  def initConnection(self):
+    connection = psycopg2.connect(
+        host=self.host,
+        database=self.database,
+        user=self.username,
+        password=self.password)
+    return connection
+
+  def randomInsertTest(self):
+    connection = self.initConnection()
+    insert = 0
+    cursor = connection.cursor()
+    createTable = """
+            CREATE TABLE IF NOT EXISTS postgres(
+                id NUMERIC,
+                word VARCHAR(50),
+                number NUMERIC,
+                date DATE,
+                bool BOOLEAN
+            )
+        """
+    cursor.execute(createTable)
+    alterTableReplica = "ALTER TABLE postgres REPLICA IDENTITY FULL;"
+    cursor.execute(alterTableReplica)
+    startTime = time.time()
+    testDuration = 60 * 22
+    timeFlag = True
+
+    logging.debug('INSERTING RANDOMLY')
+    while timeFlag:
+
+      action = random.randint(1, 10)
+      if action == 1:  # Delete

Review Comment:
   What is the purpose of inserting randomness here? Won't that make it harder for us to get a deterministic signal about whether performance has actually degraded?



##########
.test-infra/kubernetes/postgres/postgres-service-for-debezium.yml:
##########
@@ -0,0 +1,59 @@
+#    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.
+
+
+apiVersion: v1
+kind: Service
+metadata:
+  name: postgres-for-dev
+  labels:
+    name: postgres
+spec:
+  ports:
+    - port: 5432
+  selector:
+    name: postgres
+  type: LoadBalancer
+
+---
+
+apiVersion: v1
+kind: ReplicationController
+metadata:
+  name: postgres
+spec:
+  replicas: 1
+  selector:
+    name: postgres
+  template:
+    metadata:
+      name: postgres
+      labels:
+        name: postgres
+    spec:
+      containers:
+        - name: postgres
+          image: postgres
+          args: ["-c", "wal_level=logical","-c","max_wal_senders=4","-c","max_replication_slots=4"]

Review Comment:
   Why do we need these args? Seems like that is the only difference between this and postgres-for-dev, are we able to just reuse that yml file instead?



##########
.test-infra/jenkins/job_PerformanceTests_Debezium.groovy:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+import CommonJobProperties as common
+import Kubernetes
+import InfluxDBCredentialsHelper
+import LoadTestsBuilder
+
+String jobName = "beam_PerformanceTests_Debezium"
+
+String kubernetesYmlPath = "src/.test-infra/kubernetes/postgres/postgres-service-for-debezium.yml"
+
+
+String task = ":sdks:python:apache_beam:testing:load_tests:run -PloadTest.mainClass=apache_beam.testing.load_tests.debezium_performance_test -Prunner=DirectRunner"

Review Comment:
   Also, any reason to pull this out into a variable? We only use it once and it seems like the convention is to inline it. Same question for the kubernetesYmlPath.
   
   If we do keep it, we should fix the spacing.



-- 
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: github-unsubscribe@beam.apache.org

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