eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
751 stars 492 forks source link

fix failing unit tests in `gradle-plugin/it` module #3406

Open rohanKanojia opened 1 week ago

rohanKanojia commented 1 week ago

Component

None

Task description

Component

Gradle Plugin Integration Tests

Task description

Description

Related to https://github.com/eclipse/jkube/issues/1338

⚠️ A windows machine is required to reproduce and fix problems in this issue

When executing mvn clean install on Windows, the following unit tests are failing in gradle-plugin/it module:

Error:  Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.004 s <<< FAILURE! -- in org.eclipse.jkube.gradle.plugin.tests.TriggersAnnotationIT
Error:  org.eclipse.jkube.gradle.plugin.tests.TriggersAnnotationIT.ocResourceTask_whenRun_generatesOpenShiftManifestWithTriggersAnnotation -- Time elapsed: 0.457 s <<< ERROR!
java.lang.IllegalArgumentException: 
Values not equal for entry: 'image.openshift.io/triggers', expected '[ {
  "from" : {
    "kind" : "ImageStreamTag",
    "name" : "triggersannotation:latest"
  },
  "fieldPath" : "spec.template.spec.containers[?(@.name==\"orgeclipsejkubeintegrationtestsgradle-triggersannotation\")].image"
} ]' but was '[ {
  "from" : {
    "kind" : "ImageStreamTag",
    "name" : "triggersannotation:latest"
  },
  "fieldPath" : "spec.template.spec.containers[?(@.name==\"orgeclipsejkubeintegrationtestsgradle-triggersannotation\")].image"
} ]'
Error:  Errors: 
Error:    ConfigMapIT.k8sResource_whenRun_generatesK8sManifestsContainingConfigMap:37 � IllegalArgument Values not equal for entry: 'application.properties', expected 'environment = test
foo = bar' but was 'environment = test
foo = bar'
Error:    ConfigMapIT.ocResource_whenRun_generatesOpenShiftManifestsContainingConfigMap:56 � IllegalArgument Values not equal for entry: 'application.properties', expected 'environment = test
foo = bar' but was 'environment = test
foo = bar'
Error:    DependencyResourcesIT.k8sResource_whenRun_generatesK8sManifestsIncludingDependencies:36 � UnexpectedBuildFailure Unexpected build execution failure in D:\a\jkube-build-testing\jkube-build-testing\jkube\gradle-plugin\it\src\it\dependency-resources with arguments [-PjKubeVersion=null, --console=plain, clean, jar, k8sResource, --stacktrace]
Error:    FileSecretIT.k8sResource_whenRun_generatesK8sSecret:35 � IllegalArgument Values not equal for entry: 'application.properties', expected 'a2V5MSA9IHZhbHVlMQprZXkyID0gdmFsdWUyCmtleTMgPSB2YWx1ZTM=' but was 'a2V5MSA9IHZhbHVlMQ0Ka2V5MiA9IHZhbHVlMg0Ka2V5MyA9IHZhbHVlMw=='
Error:    FileSecretIT.ocResource_whenRun_generatesK8sSecret:48 � IllegalArgument Values not equal for entry: 'application.properties', expected 'a2V5MSA9IHZhbHVlMQprZXkyID0gdmFsdWUyCmtleTMgPSB2YWx1ZTM=' but was 'a2V5MSA9IHZhbHVlMQ0Ka2V5MiA9IHZhbHVlMg0Ka2V5MyA9IHZhbHVlMw=='
Error:    KubernetesExtensionIT.k8sConfigView_containsAFullyDeserializedConfiguration:39 � Validation EndsWithValidationMatcher failed for field 'resourcetargetdirectory'. Received value is 'D:\a\jkube-build-testing\jkube-build-testing\jkube\gradle-plugin\it\src\it\extension-configuration\build\META-INF\jkube', control value is 'extension-configuration/build/META-INF/jkube'.
Error:    TriggersAnnotationIT.ocResourceTask_whenRun_generatesOpenShiftManifestWithTriggersAnnotation:53 � IllegalArgument Values not equal for entry: 'image.openshift.io/triggers', expected '[ {
  "from" : {
    "kind" : "ImageStreamTag",
    "name" : "triggersannotation:latest"
  },
  "fieldPath" : "spec.template.spec.containers[?(@.name==\"orgeclipsejkubeintegrationtestsgradle-triggersannotation\")].image"
} ]' but was '[ {
  "from" : {
    "kind" : "ImageStreamTag",
    "name" : "triggersannotation:latest"
  },
  "fieldPath" : "spec.template.spec.containers[?(@.name==\"orgeclipsejkubeintegrationtestsgradle-triggersannotation\")].image"
} ]'
[INFO] 
Error:  Tests run: 220, Failures: 0, Errors: 7, Skipped: 0

I think we need to adapt these tests in order to make them work on windows:

Expected Behavior

All unit tests in gradle-plugin/it module should pass on windows

Acceptance Criteria

rexrk commented 3 days ago

Hi, I want to contribute to this issue.

rexrk commented 11 hours ago

Hello I am stuck with DependencyResourcesIT, as both the test cases runs successfully if executed individually but fails when running as whole. It seems execution of one test case locks some files in build dir making other test case to fail. what should be the approach to tackle it, kindly guide me.

`Execution failed for task ':dependency:clean'.

java.io.IOException: Unable to delete directory '{dir}\gradle-plugin\it\src\it\dependency-resources\dependency\build' Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.`