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

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

                Author: ASF GitHub Bot
            Created on: 02/Aug/19 15:05
            Start Date: 02/Aug/19 15:05
    Worklog Time Spent: 10m 
      Work Description: iemejia commented on pull request #9116: [BEAM-7776] 
Stop Using Perfkit in IOIT
URL: https://github.com/apache/beam/pull/9116#discussion_r310147265
 
 

 ##########
 File path: .test-infra/jenkins/Kubernetes.groovy
 ##########
 @@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+/** Facilitates creation of jenkins steps to setup and cleanup Kubernetes 
infrastructure. */
+class Kubernetes {
+
+  private static final String KUBERNETES_DIR = 
'"$WORKSPACE/src/.test-infra/kubernetes"'
+
+  private static final String KUBERNETES_SCRIPT = 
"${KUBERNETES_DIR}/kubernetes.sh"
+
+  private static def job
+
+  private static String kubeconfigLocation
+
+  private static String namespace
+
+  private Kubernetes(job, String kubeconfigLocation, String namespace) {
+    this.job = job
+    this.kubeconfigLocation = kubeconfigLocation
+    this.namespace = namespace
+  }
+
+  /**
+   * Creates separate kubeconfig, namespace and specifies cleanup steps for 
job using Kubernetes.
+   *
+   * @param job - jenkins job
+   * @param kubeconfigLocation - place where kubeconfig will be created
+   * @param namepsace - kubernetes namespace
+   */
+  static Kubernetes create(job, String kubeconfigLocation, String namespace) {
+    Kubernetes kubernetes = new Kubernetes(job, kubeconfigLocation, namespace)
+    setupKubeconfig()
+    setupNamespace()
+    addCleanupSteps()
+    return kubernetes
+  }
+
+  private static void setupNamespace() {
+    job.steps {
+      shell("${KUBERNETES_SCRIPT} createNamespace ${namespace}")
+      environmentVariables {
+        env('KUBERNETES_NAMESPACE', namespace)
+      }
+    }
+  }
+
+  private static void setupKubeconfig() {
+    job.steps {
+      shell("cp /home/jenkins/.kube/config ${kubeconfigLocation}")
+      environmentVariables {
+        env('KUBECONFIG', kubeconfigLocation)
+      }
+    }
+  }
+
+  private static void addCleanupSteps() {
+    job.publishers {
+      postBuildScripts {
+        steps {
+          shell("${KUBERNETES_SCRIPT} deleteNamespace ${namespace}")
+          shell("rm ${kubeconfigLocation}")
+        }
+        onlyIfBuildSucceeds(false)
+        onlyIfBuildFails(false)
+      }
+    }
+  }
+
+  /**
+   * Specifies steps to run Kubernetes .yaml script.
+   */
+  void apply(String pathToScript) {
+    job.steps {
+      shell("${KUBERNETES_SCRIPT} apply ${pathToScript}")
+    }
+  }
+
+  /**
+   * Specifies steps that will save specified load balancer serivce's address
 
 Review comment:
   service
 
----------------------------------------------------------------
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


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

    Worklog Id:     (was: 287991)
    Time Spent: 6h 20m  (was: 6h 10m)

> Implement Kubernetes setup/teardown code to gradle/jenkins tasks. 
> ------------------------------------------------------------------
>
>                 Key: BEAM-7776
>                 URL: https://issues.apache.org/jira/browse/BEAM-7776
>             Project: Beam
>          Issue Type: Sub-task
>          Components: testing
>            Reporter: Lukasz Gajowy
>            Assignee: Lukasz Gajowy
>            Priority: Major
>          Time Spent: 6h 20m
>  Remaining Estimate: 0h
>
> Currently this is done by Perfkit Benchmarker but can be easily moved to 
> Beam's codebase and a set of fine-grained gradle tasks. Those could be then 
> invoked by Jenkins giving more elasticity to our tests and making Perkfit 
> totally obsolete in IOITs. 



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to