Skip to content

Commit

Permalink
test: Add nginx to the image request
Browse files Browse the repository at this point in the history
  • Loading branch information
ezr-ondrej committed Dec 19, 2023
1 parent 33a4301 commit aa6bc9c
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 14 deletions.
26 changes: 26 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,32 @@ API:
- aws/rhel-9.2-ga-aarch64
INTERNAL_NETWORK: ["true"]

API-module-hotfixes:
stage: test
extends: .terraform
rules:
- !reference [.upstream_rules_all, rules]
# note: cloud API is not supported for on-prem installations so
# don't run this test case for nightly trees
script:
- schutzbot/deploy.sh
- /usr/libexec/tests/osbuild-composer/api.sh "${IMAGE_TYPE}" "" "${TEST_MODULE_HOTFIXES}"
parallel:
matrix:
- IMAGE_TYPE:
- aws
RUNNER:
- aws/rhel-8.8-ga-x86_64
- aws/rhel-8.8-ga-aarch64
INTERNAL_NETWORK: ["true"]
TEST_MODULE_HOTFIXES: [1]
- IMAGE_TYPE:
- vsphere
RUNNER:
- aws/rhel-8.8-ga-x86_64
INTERNAL_NETWORK: ["true"]
TEST_MODULE_HOTFIXES: [1]

.libvirt_integration:
stage: test
extends: .terraform/gcp
Expand Down
43 changes: 43 additions & 0 deletions internal/dnfjson/dnfjson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func TestMakeDepsolveRequest(t *testing.T) {
Name: "user-repo-2",
BaseURLs: []string{"https://example.org/user-repo-2"},
}
modHotfixRepo := rpmmd.RepoConfig{
Name: "nginx",
BaseURLs: []string{"https://example.org/nginx"},
ModuleHotfixes: common.ToPtr(true),
}
tests := []struct {
packageSets []rpmmd.PackageSet
args []transactionArgs
Expand Down Expand Up @@ -171,6 +176,44 @@ func TestMakeDepsolveRequest(t *testing.T) {
},
},
},
// module hotfixes flag is passed
{
packageSets: []rpmmd.PackageSet{
{
Include: []string{"pkg1"},
Exclude: []string{"pkg2"},
Repositories: []rpmmd.RepoConfig{baseOS, appstream, modHotfixRepo},
},
},
args: []transactionArgs{
{
PackageSpecs: []string{"pkg1"},
ExcludeSpecs: []string{"pkg2"},
RepoIDs: []string{baseOS.Hash(), appstream.Hash(), modHotfixRepo.Hash()},
},
},
wantRepos: []repoConfig{
{
ID: baseOS.Hash(),
Name: "baseos",
BaseURLs: []string{"https://example.org/baseos"},
repoHash: "fdc2e5bb6cda8e113308df9396a005b81a55ec00ec29aa0a447952ad4248d803",
},
{
ID: appstream.Hash(),
Name: "appstream",
BaseURLs: []string{"https://example.org/appstream"},
repoHash: "71c280f63a779a8bf53961ec2f15d51d052021de024a4e06ae499b8029701808",
},
{
ID: modHotfixRepo.Hash(),
Name: "nginx",
BaseURLs: []string{"https://example.org/nginx"},
ModuleHotfixes: common.ToPtr(true),
repoHash: "6ab05f54094ff2a0ee86facecae3e75e4065a01cc8caffbbbeb7505c6bfac283",
},
},
},
// 2 transactions + no package set specific repos
{
packageSets: []rpmmd.PackageSet{
Expand Down
9 changes: 5 additions & 4 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,11 @@ func (s *Store) GetAllDistroSources(distro string) map[string]SourceConfig {

func NewSourceConfig(repo rpmmd.RepoConfig, system bool) SourceConfig {
sc := SourceConfig{
Name: repo.Name,
System: system,
RHSM: repo.RHSM,
GPGKeys: repo.GPGKeys,
Name: repo.Name,
System: system,
RHSM: repo.RHSM,
GPGKeys: repo.GPGKeys,
ModuleHotfixes: repo.ModuleHotfixes,
}

if repo.CheckGPG != nil {
Expand Down
49 changes: 47 additions & 2 deletions test/cases/api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export IMAGE_TYPE_OCI="oci"
export IMAGE_TYPE_VSPHERE="vsphere"
export IMAGE_TYPE_IOT_COMMIT="iot-commit"

if (( $# > 2 )); then
echo "$0 does not support more than two arguments"
if (( $# > 3 )); then
echo "$0 does not support more than three arguments"
exit 1
fi

Expand All @@ -46,6 +46,7 @@ fi
set -euo pipefail

IMAGE_TYPE="$1"
TEST_MODULE_HOTFIXES="${3:-0}"

# select cloud provider based on image type
#
Expand Down Expand Up @@ -438,6 +439,39 @@ EOF
)
export FIREWALL_CUSTOMIZATION_BLOCK

if [ "$TEST_MODULE_HOTFIXES" = "1" ]; then
if [ "$ARCH" = "x86_64" ]; then
NGINX_REPO_URL="https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-x86_64-nginx-20231207"
else
NGINX_REPO_URL="https://rpmrepo.osbuild.org/v2/mirror/public/el8/el8-aarch64-nginx-20231207"
fi
EXTRA_PAYLOAD_REPOS_BLOCK=$(cat <<EOF
,
{
"baseurl": "$NGINX_REPO_URL",
"check_gpg": false,
"check_repo_gpg": false,
"rhsm": false,
"module_hotfixes": true
}
EOF
)

EXTRA_PACKAGES_BLOCK=$(cat <<EOF
,
"nginx",
"nginx-module-njs"
EOF
)

else
EXTRA_PAYLOAD_REPOS_BLOCK=""
EXTRA_PACKAGES_BLOCK=""
fi

export EXTRA_PAYLOAD_REPOS_BLOCK
export EXTRA_PACKAGES_BLOCK

# generate a temp key for user tests
ssh-keygen -t rsa-sha2-512 -f "${WORKDIR}/usertest" -C "usertest" -N ""

Expand Down Expand Up @@ -582,14 +616,25 @@ function waitForImgState() {

#
# Make sure that requesting a non existing paquet results in failure
# and if TEST_MODULE_HOTFIXES flag is passed, we verify, that without that flag the resolve fails
#

REQUEST_FILE2="${WORKDIR}/request2.json"
jq '.customizations.packages = [ "jesuisunpaquetquinexistepas" ]' "$REQUEST_FILE" > "$REQUEST_FILE2"

greenprint "Sending compose: Fail test"
sendCompose "$REQUEST_FILE2"
waitForState "failure"

if [ "$TEST_MODULE_HOTFIXES" = "1" ]; then
cat "$REQUEST_FILE"

jq 'del(.customizations.payload_repositories[] | select(.baseurl | match(".*public/el8/el8-.*-nginx-.*")) | .module_hotfixes)' "$REQUEST_FILE" > "$REQUEST_FILE2"
greenprint "Sending compose: Fail depsolve test"
sendCompose "$REQUEST_FILE2"
waitForState "failure"
fi

# crashed/stopped/killed worker should result in the job being retried
greenprint "Sending compose: Retry test"
sendCompose "$REQUEST_FILE"
Expand Down
4 changes: 2 additions & 2 deletions test/cases/api/aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ function createReqFile() {
"payload_repositories": [
{
"baseurl": "$PAYLOAD_REPO_URL"
}
}${EXTRA_PAYLOAD_REPOS_BLOCK}
],
"packages": [
"postgresql",
"dummy"
"dummy"${EXTRA_PACKAGES_BLOCK}
],
"users":[
{
Expand Down
12 changes: 6 additions & 6 deletions test/cases/api/common/s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ function createReqFileEdge() {
"payload_repositories": [
{
"baseurl": "$PAYLOAD_REPO_URL"
}
}${EXTRA_PAYLOAD_REPOS_BLOCK}
],
"packages": [
"postgresql",
"dummy"
"dummy"${EXTRA_PACKAGES_BLOCK}
],
"users":[
{
Expand Down Expand Up @@ -67,11 +67,11 @@ function createReqFileGuest() {
"payload_repositories": [
{
"baseurl": "$PAYLOAD_REPO_URL"
}
}${EXTRA_PAYLOAD_REPOS_BLOCK}
],
"packages": [
"postgresql",
"dummy"
"dummy"${EXTRA_PACKAGES_BLOCK}
],
"users":[
{
Expand Down Expand Up @@ -108,11 +108,11 @@ function createReqFileVSphere() {
"payload_repositories": [
{
"baseurl": "$PAYLOAD_REPO_URL"
}
}${EXTRA_PAYLOAD_REPOS_BLOCK}
],
"packages": [
"postgresql",
"dummy"
"dummy"${EXTRA_PACKAGES_BLOCK}
]${SUBSCRIPTION_BLOCK}${DIR_FILES_CUSTOMIZATION_BLOCK}
${TIMEZONE_CUSTOMIZATION_BLOCK}${FIREWALL_CUSTOMIZATION_BLOCK}
},
Expand Down

0 comments on commit aa6bc9c

Please sign in to comment.