[ 
https://issues.apache.org/jira/browse/BEAM-7872?focusedWorklogId=301112&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-301112
 ]

ASF GitHub Bot logged work on BEAM-7872:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Aug/19 09:16
            Start Date: 26/Aug/19 09:16
    Worklog Time Spent: 10m 
      Work Description: kamilwu commented on pull request #9213: [BEAM-7872] 
Simpler Flink cluster set up in load tests
URL: https://github.com/apache/beam/pull/9213#discussion_r317520341
 
 

 ##########
 File path: .test-infra/jenkins/Flink.groovy
 ##########
 @@ -0,0 +1,114 @@
+/*
+ * 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 DockerPublisher
+
+class Flink {
+  private static final String flinkVersion = '1.7'
+  private static final String flinkDownloadUrl = 
'https://archive.apache.org/dist/flink/flink-1.7.0/flink-1.7.0-bin-hadoop28-scala_2.11.tgz'
+  private static final String FLINK_DIR = 
'"$WORKSPACE/src/.test-infra/dataproc"'
+  private static final String FLINK_SCRIPT = 'flink_cluster.sh'
+  private def job
+  private String jobName
+  private String jobServerImageTag
+
+  Flink(job, String jobName) {
+    this.job = job
+    this.jobName = jobName
+    this.jobServerImageTag = ''
+  }
+
+  /**
+   * Creates Flink cluster and specifies cleanup steps.
+   *
+   * @param sdkHarnessImages - the list of published SDK Harness images tags
+   * @param workerCount - the initial number of worker nodes
+   * @param slotsPerTaskmanager - the number of slots per Flink task manager
+   */
+  void setUp(List<String> sdkHarnessImages, Integer workerCount, Integer 
slotsPerTaskmanager = 1) {
+    setupFlinkCluster(sdkHarnessImages, workerCount, slotsPerTaskmanager)
+    addTeardownFlinkStep()
+  }
+
+  /**
+   * Updates the number of worker nodes in a cluster.
+   *
+   * @param workerCount - the new number of worker nodes in the cluster
+   */
+  void scaleCluster(Integer workerCount) {
+    job.steps {
+      shell("echo Changing number of workers to ${workerCount}")
+      environmentVariables {
+        env("FLINK_NUM_WORKERS", workerCount)
+      }
+      shell("cd ${FLINK_DIR}; ./${FLINK_SCRIPT} scale")
+    }
+  }
+
+  void prepareJobServer(DockerPublisher jobServerPublisher = new 
DockerPublisher()) {
+    this.jobServerImageTag = 
jobServerPublisher.getFullImageName('flink-job-server')
+    jobServerPublisher.publish(job, 
":runners:flink:${flinkVersion}:job-server-container:docker", 
'flink-job-server')
+  }
+
+  private void setupFlinkCluster(List<String> sdkHarnessImages, Integer 
workerCount, Integer slotsPerTaskmanager) {
+    String gcsBucket = 'gs://beam-flink-cluster'
+    String clusterName = getClusterName()
+    String artifactsDir = "${gcsBucket}/${clusterName}"
+    String imagesToPull = sdkHarnessImages.join(' ')
+
+    job.steps {
+      environmentVariables {
+        env("GCLOUD_ZONE", "us-central1-a")
+        env("CLUSTER_NAME", clusterName)
+        env("GCS_BUCKET", gcsBucket)
+        env("FLINK_DOWNLOAD_URL", flinkDownloadUrl)
+        env("FLINK_NUM_WORKERS", workerCount)
+        env("FLINK_TASKMANAGER_SLOTS", slotsPerTaskmanager)
+        env("DETACHED_MODE", 'true')
+
+        if(imagesToPull) {
+          env("HARNESS_IMAGES_TO_PULL", imagesToPull)
+        }
+
+        if(jobServerImageTag) {
+          env("JOB_SERVER_IMAGE", jobServerImageTag)
+          env("ARTIFACTS_DIR", artifactsDir)
+        }
+      }
+
+      shell('echo Setting up flink cluster')
+      shell("cd ${FLINK_DIR}; ./${FLINK_SCRIPT} create")
+    }
+  }
+
+  private void addTeardownFlinkStep() {
+    job.publishers {
+      postBuildScripts {
+        steps {
+          shell("cd ${FLINK_DIR}; ./${FLINK_SCRIPT} delete")
+        }
+        onlyIfBuildSucceeds(false)
+        onlyIfBuildFails(false)
+      }
+    }
+  }
+
+  private GString getClusterName() {
 
 Review comment:
   Totally agree. Thanks for spotting this.
 
----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 301112)
    Time Spent: 12h  (was: 11h 50m)

> Simpler Flink cluster set up in load tests
> ------------------------------------------
>
>                 Key: BEAM-7872
>                 URL: https://issues.apache.org/jira/browse/BEAM-7872
>             Project: Beam
>          Issue Type: Sub-task
>          Components: testing
>            Reporter: Kamil Wasilewski
>            Assignee: Kamil Wasilewski
>            Priority: Major
>          Time Spent: 12h
>  Remaining Estimate: 0h
>
> Creating a new load test running on Flink runner could be easier by providing 
> a single `setUp` function which would encapsulate the process of creating 
> Flink cluster and registering teardown steps



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to