Skip to content

Commit

Permalink
Add lifecycle index in benchmark update messages.
Browse files Browse the repository at this point in the history
Signed-off-by: Nashwan Azhari <nazhari@cloudbasesolutions.com>
  • Loading branch information
aznashwan committed May 5, 2022
1 parent 5757376 commit e0b9a56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
15 changes: 8 additions & 7 deletions pkg/benchmark/container.go
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package benchmark

import (
"fmt"
"path"
"time"

Expand Down Expand Up @@ -85,35 +86,35 @@ var _ = framework.KubeDescribe("Container", func() {

podID, podConfig = framework.CreatePodSandboxForContainer(rc)

By("CreatingContainer")
By(fmt.Sprintf("CreatingContainer %d", idx))
startTime := time.Now().UnixNano()
lastStartTime = startTime
containerID = framework.CreateDefaultContainer(rc, ic, podID, podConfig, "Benchmark-container-")
lastEndTime = time.Now().UnixNano()
durations[0] = lastEndTime - lastStartTime

By("StartingContainer")
By(fmt.Sprintf("StartingContainer %d", idx))
lastStartTime = time.Now().UnixNano()
err = rc.StartContainer(containerID)
lastEndTime = time.Now().UnixNano()
durations[1] = lastEndTime - lastStartTime
framework.ExpectNoError(err, "failed to start Container: %v", err)

By("ContainerStatus")
By(fmt.Sprintf("ContainerStatus %d", idx))
lastStartTime = time.Now().UnixNano()
_, err = rc.ContainerStatus(containerID, true)
lastEndTime = time.Now().UnixNano()
durations[2] = lastEndTime - lastStartTime
framework.ExpectNoError(err, "failed to get Container status: %v", err)

By("ContainerStop")
By(fmt.Sprintf("ContainerStop %d", idx))
lastStartTime = time.Now().UnixNano()
err = rc.StopContainer(containerID, framework.DefaultStopContainerTimeout)
lastEndTime = time.Now().UnixNano()
durations[3] = lastEndTime - lastStartTime
framework.ExpectNoError(err, "failed to stop Container: %v", err)

By("ContainerRemove")
By(fmt.Sprintf("ContainerRemove %d", idx))
lastStartTime = time.Now().UnixNano()
err = rc.RemoveContainer(containerID)
lastEndTime = time.Now().UnixNano()
Expand All @@ -129,9 +130,9 @@ var _ = framework.KubeDescribe("Container", func() {
}
resultsChannel <- &res

By("stop PodSandbox")
By(fmt.Sprintf("stop PodSandbox %d", idx))
rc.StopPodSandbox(podID)
By("delete PodSandbox")
By(fmt.Sprintf("delete PodSandbox %d", idx))
rc.RemovePodSandbox(podID)

}, samplingConfig)
Expand Down
9 changes: 5 additions & 4 deletions pkg/benchmark/image.go
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package benchmark

import (
"fmt"
"path"
"runtime"
"time"
Expand Down Expand Up @@ -124,21 +125,21 @@ var _ = framework.KubeDescribe("Image", func() {
Image: imagePullingBenchmarkImage,
}

By("Pull Image")
By(fmt.Sprintf("Pull Image %d", idx))
startTime := time.Now().UnixNano()
lastStartTime = startTime
imageId := framework.PullPublicImage(ic, imagePullingBenchmarkImage, nil)
lastEndTime = time.Now().UnixNano()
durations[0] = lastEndTime - lastStartTime

By("Status Image")
By(fmt.Sprintf("Status Image %d", idx))
lastStartTime = startTime
_, err = ic.ImageStatus(imageSpec, false)
lastEndTime = time.Now().UnixNano()
durations[1] = lastEndTime - lastStartTime
framework.ExpectNoError(err, "failed to status Image: %v", err)

By("Remove Image")
By(fmt.Sprintf("Remove Image %d", idx))
lastStartTime = startTime
err = ic.RemoveImage(imageSpec)
lastEndTime = time.Now().UnixNano()
Expand Down Expand Up @@ -211,7 +212,7 @@ var _ = framework.KubeDescribe("Image", func() {
var err error
durations := make([]int64, len(imageListResultsSet.OperationsNames))

By("List Images")
By(fmt.Sprintf("List Images %d", idx))
startTime := time.Now().UnixNano()
_, err = ic.ListImages(nil)
endTime := time.Now().UnixNano()
Expand Down
9 changes: 5 additions & 4 deletions pkg/benchmark/pod.go
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package benchmark

import (
"fmt"
"path"
"time"

Expand Down Expand Up @@ -90,29 +91,29 @@ var _ = framework.KubeDescribe("PodSandbox", func() {
Labels: framework.DefaultPodLabels,
}

By("Creating a pod")
By(fmt.Sprintf("Creating a pod %d", idx))
startTime := time.Now().UnixNano()
lastStartTime = startTime
podID, err = c.RunPodSandbox(config, framework.TestContext.RuntimeHandler)
lastEndTime = time.Now().UnixNano()
durations[0] = lastEndTime - lastStartTime
framework.ExpectNoError(err, "failed to create PodSandbox: %v", err)

By("Get Pod status")
By(fmt.Sprintf("Get Pod status %d", idx))
lastStartTime = time.Now().UnixNano()
_, err = c.PodSandboxStatus(podID, true)
lastEndTime = time.Now().UnixNano()
durations[1] = lastEndTime - lastStartTime
framework.ExpectNoError(err, "failed to get PodStatus: %v", err)

By("Stop PodSandbox")
By(fmt.Sprintf("Stop PodSandbox %d", idx))
lastStartTime = time.Now().UnixNano()
err = c.StopPodSandbox(podID)
lastEndTime = time.Now().UnixNano()
durations[2] = lastEndTime - lastStartTime
framework.ExpectNoError(err, "failed to stop PodSandbox: %v", err)

By("Remove PodSandbox")
By(fmt.Sprintf("Remove PodSandbox %d", idx))
lastStartTime = time.Now().UnixNano()
err = c.RemovePodSandbox(podID)
lastEndTime = time.Now().UnixNano()
Expand Down

0 comments on commit e0b9a56

Please sign in to comment.