...

Source file src/k8s.io/kubernetes/test/e2e_node/perf/workloads/npb_is.go

Documentation: k8s.io/kubernetes/test/e2e_node/perf/workloads

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package workloads
    18  
    19  import (
    20  	"fmt"
    21  	"strings"
    22  	"time"
    23  
    24  	v1 "k8s.io/api/core/v1"
    25  	"k8s.io/apimachinery/pkg/api/resource"
    26  	kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
    27  	imageutils "k8s.io/kubernetes/test/utils/image"
    28  )
    29  
    30  // npbISWorkload defines a workload to run the integer sort (IS) workload
    31  // from NAS parallel benchmark (NPB) suite.
    32  type npbISWorkload struct{}
    33  
    34  // Ensure npbISWorkload implements NodePerfWorkload interface.
    35  var _ NodePerfWorkload = &npbISWorkload{}
    36  
    37  func (w npbISWorkload) Name() string {
    38  	return "npb-is"
    39  }
    40  
    41  func (w npbISWorkload) PodSpec() v1.PodSpec {
    42  	var containers []v1.Container
    43  	ctn := v1.Container{
    44  		Name:  fmt.Sprintf("%s-ctn", w.Name()),
    45  		Image: imageutils.GetE2EImage(imageutils.NodePerfNpbIs),
    46  		Resources: v1.ResourceRequirements{
    47  			Requests: v1.ResourceList{
    48  				v1.ResourceName(v1.ResourceCPU):    resource.MustParse("15000m"),
    49  				v1.ResourceName(v1.ResourceMemory): resource.MustParse("48Gi"),
    50  			},
    51  			Limits: v1.ResourceList{
    52  				v1.ResourceName(v1.ResourceCPU):    resource.MustParse("15000m"),
    53  				v1.ResourceName(v1.ResourceMemory): resource.MustParse("48Gi"),
    54  			},
    55  		},
    56  		Command: []string{"/bin/sh"},
    57  		Args:    []string{"-c", "/is.D.x"},
    58  	}
    59  	containers = append(containers, ctn)
    60  
    61  	return v1.PodSpec{
    62  		RestartPolicy: v1.RestartPolicyNever,
    63  		Containers:    containers,
    64  	}
    65  }
    66  
    67  func (w npbISWorkload) Timeout() time.Duration {
    68  	return 4 * time.Minute
    69  }
    70  
    71  func (w npbISWorkload) KubeletConfig(oldCfg *kubeletconfig.KubeletConfiguration) (newCfg *kubeletconfig.KubeletConfiguration, err error) {
    72  	return oldCfg, nil
    73  }
    74  
    75  func (w npbISWorkload) PreTestExec() error {
    76  	return nil
    77  }
    78  
    79  func (w npbISWorkload) PostTestExec() error {
    80  	return nil
    81  }
    82  
    83  func (w npbISWorkload) ExtractPerformanceFromLogs(logs string) (perf time.Duration, err error) {
    84  	perfLine, err := getMatchingLineFromLog(logs, "Time in seconds =")
    85  	if err != nil {
    86  		return perf, err
    87  	}
    88  	perfStrings := strings.Split(perfLine, "=")
    89  	perfString := fmt.Sprintf("%ss", strings.TrimSpace(perfStrings[1]))
    90  	perf, err = time.ParseDuration(perfString)
    91  
    92  	return perf, err
    93  }
    94  

View as plain text