Skip to content

Commit

Permalink
test: compare image commit (dragonflyoss#538)
Browse files Browse the repository at this point in the history
* feat: compare image commit

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Aug 12, 2021
1 parent 0cc52f5 commit 894c7d9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/helm-charts
23 changes: 23 additions & 0 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package e2e

import (
"fmt"
"strings"
"testing"

Expand All @@ -25,6 +26,28 @@ import (
. "github.com/onsi/gomega" //nolint
)

var _ = BeforeSuite(func() {
out, err := e2eutil.GitCommand("rev-parse", "--short", "HEAD").CombinedOutput()
Expect(err).NotTo(HaveOccurred())
gitCommit := strings.Fields(string(out))[0]
fmt.Println(gitCommit)

out, err = e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=dfdaemon",
"-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput()
podName := strings.Trim(string(out), "'")
Expect(err).NotTo(HaveOccurred())
fmt.Println(podName)

Expect(strings.HasPrefix(podName, "dragonfly-dfdaemon-")).Should(BeTrue())
pod := e2eutil.NewPodExec(dragonflyNamespace, podName, "dfdaemon")
out, err = pod.Command("dfget", "version").CombinedOutput()
Expect(err).NotTo(HaveOccurred())
dfgetGitCommit := strings.Fields(string(out))[7]
fmt.Println(dfgetGitCommit)

Expect(gitCommit).To(Equal(dfgetGitCommit))
})

var _ = AfterSuite(func() {
out, err := e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=dfdaemon",
"-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput()
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/e2eutil/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func ABCommand(arg ...string) *exec.Cmd {
return exec.Command("ab", arg...)
}

func GitCommand(arg ...string) *exec.Cmd {
return exec.Command("git", arg...)
}

type PodExec struct {
namespace string
name string
Expand Down

0 comments on commit 894c7d9

Please sign in to comment.