File: digest.bats

package info (click to toggle)
golang-github-containers-buildah 1.39.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,724 kB
  • sloc: sh: 2,398; makefile: 236; perl: 187; asm: 16; awk: 12; ansic: 1
file content (80 lines) | stat: -rw-r--r-- 2,763 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bats

load helpers

fromreftest() {
  local img=$1

  run_buildah from --quiet --pull $WITH_POLICY_JSON $img
  cid=$output

  # If image includes '_v2sN', verify that image is schema version N
  local expected_schemaversion=$(expr "$img" : '.*_v2s\([0-9]\)')
  if [ -n "$expected_schemaversion" ]; then
      actual_schemaversion=$(imgtype -expected-manifest-type '*' -show-manifest $img | jq .schemaVersion)
      expect_output --from="$actual_schemaversion" "$expected_schemaversion" \
                    ".schemaversion of $img"
  fi

  # This is all we test: basically, that buildah doesn't crash when pushing
  pushdir=${TEST_SCRATCH_DIR}/fromreftest
  mkdir -p ${pushdir}/{1,2,3}
  run_buildah push $WITH_POLICY_JSON $img dir:${pushdir}/1
  run_buildah commit $WITH_POLICY_JSON $cid new-image
  run_buildah push $WITH_POLICY_JSON new-image dir:${pushdir}/2
  run_buildah rmi new-image
  run_buildah commit $WITH_POLICY_JSON $cid dir:${pushdir}/3

  run_buildah rm $cid
  rm -fr ${pushdir}
}

@test "from-by-digest-s1" {
  test -n "$CI_USE_REGISTRY_CACHE" && skip "Cannot test against local cache registry"

  skip_if_rootless_environment
  fromreftest quay.io/libpod/testdigest_v2s1@sha256:816563225d7baae4782653efc9410579341754fe32cbe20f7600b39fc37d8ec7
}

@test "from-by-digest-s1-a-discarded-layer" {
  test -n "$CI_USE_REGISTRY_CACHE" && skip "Cannot test against local cache registry"

  skip_if_rootless_environment
  IMG=quay.io/libpod/testdigest_v2s1_with_dups@sha256:2c619fffbed29d8677e246798333e7d1b288333cb61c020575f6372c76fdbb52

  fromreftest ${IMG}

  # Verify that image meets our expectations (duplicate layers)
  # Surprisingly, we do this after fromreftest, not before, because fromreftest
  # has to pull the image for us.
  #
  # Check that the first and second .fsLayers and .history elements are dups
  local manifest=$(imgtype -expected-manifest-type '*' -show-manifest ${IMG})
  for element in fsLayers history; do
      local first=$(jq ".${element}[0]" <<<"$manifest")
      local second=$(jq ".${element}[1]" <<<"$manifest")
      expect_output --from="$second" "$first" "${IMG}: .${element}[1] == [0]"
  done
}

@test "from-by-tag-s1" {
  test -n "$CI_USE_REGISTRY_CACHE" && skip "Cannot test against local cache registry"

  skip_if_rootless_environment
  fromreftest quay.io/libpod/testdigest_v2s1:20200210
}

@test "from-by-digest-s2" {
  skip_if_rootless_environment
  fromreftest quay.io/libpod/testdigest_v2s2@sha256:755f4d90b3716e2bf57060d249e2cd61c9ac089b1233465c5c2cb2d7ee550fdb
}

@test "from-by-tag-s2" {
  skip_if_rootless_environment
  fromreftest quay.io/libpod/testdigest_v2s2:20200210
}

@test "from-by-repo-only-s2" {
  skip_if_rootless_environment
  fromreftest quay.io/libpod/testdigest_v2s2
}