Skip to content

Commit

Permalink
Fix E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
nesmabadr committed Nov 24, 2023
1 parent 63af06a commit c979a91
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/test-e2e-create-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ jobs:
steps:
- name: Checkout Kyma CLI
uses: actions/checkout@v3
with:
path: cli
- name: Set up Go
uses: actions/setup-go@v4
working-directory: cli
with:
go-version-file: 'go.mod'
cache-dependency-path: 'go.sum'
- name: Build Kyma CLI
working-directory: cli
run: |
make resolve validate build-linux
chmod +x ./bin/kyma-linux
Expand All @@ -40,17 +44,18 @@ jobs:
uses: actions/checkout@v3
with:
repository: kyma-project/template-operator
path: ./template-operator/
path: template-operator
- name: export template-operator URL
working-directory: template-operator
run: |
cd ./template-operator
echo "TEST_REPOSITORY_URL=$(git remote get-url origin)" >> "$GITHUB_ENV"
- name: Set up k3d
run: wget -qO - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=$K3D_VERSION bash
- name: Provision OCI Registry
run: |
k3d registry create oci.localhost --port 5001
- name: Run create module with kubebuilder-project
working-directory: template-operator
if: ${{ matrix.e2e-test == 'test-kubebuilder-module-creation' }}
run: |
kyma alpha create module \
Expand All @@ -64,9 +69,9 @@ jobs:
--sec-scanners-config ./template-operator/sec-scanners-config.yaml
echo "MODULE_TEMPLATE_PATH=/tmp/kubebuilder-template.yaml" >> "$GITHUB_ENV"
- name: Run create module with module-config
working-directory: template-operator
if: ${{ matrix.e2e-test == 'test-moduleconfig-module-creation' || matrix.e2e-test == 'test-same-version-module-creation'}}
run: |
cd ./template-operator
make build-manifests
kyma alpha create module \
--name kyma-project.io/module/template-operator \
Expand All @@ -79,9 +84,9 @@ jobs:
--output /tmp/module-config-template.yaml
echo "MODULE_TEMPLATE_PATH=/tmp/module-config-template.yaml" >> "$GITHUB_ENV"
- name: Create a different security scanners config file for different layers
working-directory: template-operator
if: ${{matrix.e2e-test == 'test-same-version-module-creation'}}
run: |
cd ./template-operator
echo 'module-name: template-operator
rc-tag: 0.5.0
dev-branch: main
Expand All @@ -93,11 +98,13 @@ jobs:
- "**/test/**"
- "**/*_test.go"' > sec-scanners-config-changed.yaml
- name: Verify module template
working-directory: cli
if: ${{ matrix.e2e-test == 'test-moduleconfig-module-creation' || matrix.e2e-test == 'test-kubebuilder-module-creation'}}
run: |
echo $MODULE_TEMPLATE_PATH
make -C tests/e2e test-module-creation
- name: Run E2E tests
working-directory: cli
if: ${{ matrix.e2e-test == 'test-same-version-module-creation'}}
run: |
echo $MODULE_TEMPLATE_PATH
Expand Down
2 changes: 0 additions & 2 deletions internal/cli/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"k8s.io/klog/v2"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
)

// NewLogger returns the logger used for CLI log output (used in Hydroform deployments)
Expand All @@ -26,7 +25,6 @@ func NewLogger(printLogs bool) *zap.Logger {
logger = zap.NewNop()
}
logr := zapr.NewLoggerWithOptions(logger)
ctrllog.SetLogger(zapr.NewLoggerWithOptions(zap.NewNop()))
klog.SetLogger(logr)
ocm.DefaultContext().LoggingContext().SetBaseLogger(logr)
ocm.DefaultContext().LoggingContext().SetDefaultLevel(9)
Expand Down
26 changes: 18 additions & 8 deletions pkg/module/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ func (r *Remote) Push(archive *comparch.ComponentArchive, overwrite bool) (ocm.C
if descriptorResourcesAreEquivalent(archive.GetDescriptor().Resources,
versionAccess.GetDescriptor().Resources) {
return versionAccess, false, nil
} else {
return nil, false, fmt.Errorf("version %s already exists with different content, please use "+
"--module-archive-version-overwrite flag to overwrite it",
archive.ComponentVersionAccess.GetVersion())
}
return nil, false, fmt.Errorf("version %s already exists with different content, please use "+
"--module-archive-version-overwrite flag to overwrite it",
archive.ComponentVersionAccess.GetVersion())
}
}

Expand Down Expand Up @@ -201,15 +200,26 @@ func descriptorResourcesAreEquivalent(localResources, remoteResources compdesc.R
for _, res := range remoteResources {
localResource := localResourcesMap[res.Name]
if res.Name == RawManifestLayerName {
remoteAccessObject := res.Access.(*runtime.UnstructuredVersionedTypedObject).Object
_, ok := localResourcesMap[res.Name]
remoteAccess, ok := res.Access.(*runtime.UnstructuredVersionedTypedObject)
if !ok {
return false
}
localAccessObject := localResource.Access.(*localblob.AccessSpec)

_, ok = localResourcesMap[res.Name]
if !ok {
return false
}
localAccessObject, ok := localResource.Access.(*localblob.AccessSpec)
if !ok {
return false
}

remoteAccessLocalReference, ok := remoteAccess.Object[accessLocalReferenceFieldName].(string)
if !ok {
return false
}
// Trimming 7 characters because locally the sha256 is followed by '.' but remote it is followed by ':'
if remoteAccessObject[accessLocalReferenceFieldName].(string)[7:] != localAccessObject.LocalReference[7:] {
if remoteAccessLocalReference[7:] != localAccessObject.LocalReference[7:] {
return false
}
} else if !res.IsEquivalent(&localResource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func Test_SameVersion_ModuleCreation(t *testing.T) {
assert.Nil(t, err)
})

t.Run("Create same version module but different content without module-archive-version-overwrite flag",
t.Run("Create same version module, but different content without module-archive-version-overwrite flag",
func(t *testing.T) {
err := e2e.CreateModuleCommand(false, path, registry, configFilePath, version, changedsecScannerConfigFile)
assert.Equal(t, e2e.ErrCreateModuleFailedWithSameVersion, err)
Expand Down

0 comments on commit c979a91

Please sign in to comment.