Skip to content

Commit

Permalink
skip TestVerifiedHash when internet connectivity is slow or missing
Browse files Browse the repository at this point in the history
this adds a way to skip tests by setting the env variable
CRC_IN_DISCONNECTED_ENV to true

this is added to skip the tests primarily in brew environment where
outside connectivity is not present and hence the test fails
  • Loading branch information
anjannath committed Sep 27, 2023
1 parent 71615e7 commit d80016c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packaging/rpm/crc.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export GOFLAGS="-mod=vendor"
mkdir embed-files
cp /usr/bin/crc-driver-libvirt embed-files
cp /usr/bin/crc-admin-helper embed-files/crc-admin-helper-linux
make COMMIT_SHA=__COMMIT_SHA__ GO_EXTRA_LDFLAGS="-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" GO_EXTRA_BUILDFLAGS="" CUSTOM_EMBED=true EMBED_DOWNLOAD_DIR=embed-files/ release
make CRC_IN_DISCONNECTED_ENV=true COMMIT_SHA=__COMMIT_SHA__ GO_EXTRA_LDFLAGS="-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" GO_EXTRA_BUILDFLAGS="" CUSTOM_EMBED=true EMBED_DOWNLOAD_DIR=embed-files/ release

%install
# with fedora macros: gopkginstall
Expand Down
7 changes: 7 additions & 0 deletions pkg/crc/machine/bundle/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package bundle
import (
"encoding/json"
"fmt"
"os"
"strconv"
"strings"
"testing"
"unicode"
Expand Down Expand Up @@ -188,6 +190,11 @@ func TestGetBundleType(t *testing.T) {
}

func TestVerifiedHash(t *testing.T) {
// skip the test when running in disconnected env
if disonnected, _ := strconv.ParseBool(os.Getenv("CRC_IN_DISCONNECTED_ENV")); disonnected {
t.Skip("Skipping test since running in disconnected env")
}

sha256sum, err := getVerifiedHash("https://developers.redhat.com/content-gateway/file/pub/openshift-v4/clients/crc/bundles/openshift/4.13.0/sha256sum.txt.sig", "crc_libvirt_4.13.0_amd64.crcbundle")
require.NoError(t, err)
require.Equal(t, "6aad57019aaab95b670378f569b3f4a16398da0358dd1057996453a8d6d92212", sha256sum)
Expand Down

0 comments on commit d80016c

Please sign in to comment.