Skip to content

Commit

Permalink
fix: Testing fixes and adapting to the latest version (#1811)
Browse files Browse the repository at this point in the history
Reviewed-by: Alexander Jung <[email protected]>
Approved-by: Alexander Jung <[email protected]>
  • Loading branch information
nderjung authored Aug 5, 2024
2 parents 2e45210 + dae1250 commit 1fc64fb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/tests-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ jobs:
os: [ubuntu-24.04, ubuntu-22.04, macos-12, macos-13, macos-14, mac-m2-14]
runs-on: ${{ matrix.os }}
steps:
- name: Generate Suffix
shell: bash
id: suffix
run: echo "suffix=$(date +%s)" >> "$GITHUB_OUTPUT"

- name: Set up BuildKit
shell: bash
run: |
docker run \
--rm \
-itd \
--privileged \
--name "buildkitd_${GITHUB_RUN_ID}_${SUFFIX}" \
-v /run/buildkit:/run/buildkit:rw \
moby/buildkit:v0.14.1;
timeout 60 bash -c 'while [ ! -S "/run/buildkit/buildkitd.sock" ]; do sleep 1; done'
sudo chmod 666 /run/buildkit/buildkitd.sock;
env:
SUFFIX: ${{ steps.suffix.outputs.suffix }}

- uses: actions/checkout@v4
with:
submodules: recursive
Expand Down Expand Up @@ -43,6 +63,11 @@ jobs:
- name: Run tests
run: make test-unit

- name: Stop BuildKit
if: always()
shell: bash
run: docker stop "buildkitd_${GITHUB_RUN_ID}_${{ steps.suffix.outputs.suffix }}" || true

e2e-cli:
strategy:
fail-fast: false
Expand Down
23 changes: 11 additions & 12 deletions test/e2e/cloud/instance_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func urlParser(stdout *fcmd.IOStream) string {
}

func serviceParser(stdout *fcmd.IOStream) string {
if strings.Contains(stdout.String(), "service_group\":") {
services := strings.SplitN(stdout.String(), "service_group\":\"", 2)[1]
if strings.Contains(stdout.String(), "service\":") {
services := strings.SplitN(stdout.String(), "service\":\"", 2)[1]
services = strings.SplitN(services, "\"", 2)[0]
return services
}
Expand Down Expand Up @@ -209,7 +209,7 @@ var _ = Describe("kraft cloud instance create", func() {
Expect(err).ToNot(HaveOccurred())

Expect(stderr.String()).To(BeEmpty())
Expect(stdout.String()).To(MatchRegexp(`Create an instance on KraftCloud from an image.\n`))
Expect(stdout.String()).To(MatchRegexp(`Create an instance on Unikraft Cloud from an image.\n`))
})
})

Expand Down Expand Up @@ -388,7 +388,7 @@ var _ = Describe("kraft cloud instance create", func() {
Expect(err).To(HaveOccurred())

Expect(stdout.String()).ToNot(BeEmpty())
Expect(stdout.String()).To(MatchRegexp(`flag: strconv.ParseUint: parsing`))
Expect(stdout.String()).To(MatchRegexp(`memory must be at least 1Mi`))
})
})

Expand Down Expand Up @@ -446,7 +446,7 @@ var _ = Describe("kraft cloud instance create", func() {
Expect(err).To(HaveOccurred())

Expect(stdout.String()).ToNot(BeEmpty())
Expect(stdout.String()).To(MatchRegexp(`strconv\.ParseUint: parsing \\"16\.56\\": invalid syntax`))
Expect(stdout.String()).To(MatchRegexp(`memory must be at least 1Mi`))
})
})

Expand Down Expand Up @@ -475,7 +475,7 @@ var _ = Describe("kraft cloud instance create", func() {
Expect(err).To(HaveOccurred())

Expect(stdout.String()).ToNot(BeEmpty())
Expect(stdout.String()).To(MatchRegexp(`strconv.ParseUint: parsing \\"seventeen\\": invalid syntax`))
Expect(stdout.String()).To(MatchRegexp(`could not parse memory quantity: quantities must match the regular expression`))
})
})

Expand Down Expand Up @@ -756,14 +756,13 @@ var _ = Describe("kraft cloud instance create", func() {
)
})

It("should error out with an API error", func() {
It("should not error out with an API error", func() {
err := cmd.Run()
time.Sleep(2 * time.Second)
Expect(err).To(HaveOccurred())
Expect(err).ToNot(HaveOccurred())

Expect(stderr.String()).To(BeEmpty())
Expect(stdout.String()).ToNot(BeEmpty())
Expect(stdout.String()).To(MatchRegexp(`Invalid name`))
})
})

Expand Down Expand Up @@ -1684,7 +1683,7 @@ var _ = Describe("kraft cloud instance create", func() {
"--port", instancePortMap,
"--memory", instanceMemory,
"--name", instanceNameFull,
"--domain", "smth-"+instanceNameFull,
"--domain", "smth-"+instanceNameFull+".xyz",
"--start",
imageName,
)
Expand Down Expand Up @@ -1873,7 +1872,7 @@ var _ = Describe("kraft cloud instance create", func() {
cmd.Args = append(cmd.Args,
"--port", instancePortMap,
"--name", instanceNameFull,
"--scale-to-zero",
"--scale-to-zero", "on",
imageName,
)
})
Expand Down Expand Up @@ -2418,7 +2417,7 @@ var _ = Describe("kraft cloud instance create", func() {

Expect(stderr.String()).To(BeEmpty())
Expect(stdout.String()).ToNot(BeEmpty())
Expect(stdout.String()).To(MatchRegexp(`No service with name 'smth`))
Expect(stdout.String()).To(MatchRegexp(`No service group with name 'smth`))
})
})

Expand Down

0 comments on commit 1fc64fb

Please sign in to comment.