Closed RadekKoubsky closed 6 years ago
I have tried the code with Arquillian Cube 1.8.0, the issue with image stream is still present.
@RadekKoubsky I have started working on this. Any thought where the error could happen? I am asking just to not going completely blind.
@RadekKoubsky I have been reading the issue and running the example and I have noticed that I am not sure if an error on Cube or if you have another scenario in mind but look when you do:
mvn clean fabric8:deploy -Popenshift
mvn verify -Popenshift-it -Dnamespace.use.existing=my-project -Denv.init.enabled=false
It works. And it works because fabric8:deploy
generates the kubernetes resource and deploy it to OpenShift and then test is run, and since everything is deployed it works.
Then you say that using just thins command:
mvn clean verify -Popenshift,openshift-it -Dnamespace.use.existing=my-project -Denv.init.enabled=true
Does not work. Basically it does not work because Arquillian is not deploying the scenario, but here is my question. There is no really advantage of using first instead of second approach. In terms of CI/CD it doesn't care since it is Jenkinsfile who does everything. In terms of development in terminal, well he can create a shell script and run it from build tool (Maven), create an alias or whatever. Then there is if developer is running from IDE, in this case is where it is interesting that Arquillian could deploy the services but you still need the manual step of generating the kubernetes file, so again if you need a manual step, it is not so automatic at all.
The only thing I see is that you can generate kubernetes file with maven call then switch to IDE and run the test from there, but then not sure it is valid from UX.
Am I missing something?
@lordofthejars The correct one to speak to is @spisiakm, as @RadekKoubsky is leaving Red Hat.
Actually the 1st scenario, the one with 2 Maven invocations, is something we don't want. We want the second one to work, the one with a single Maven invocation.
Ok great, welcome @spisiakm, but what is the benefit of the second one if you still need one manual step?
Sorry, not sure I'm following. Here's a somewhat more recent description of the issue: https://github.com/openshiftio/appdev-planning/issues/43#issuecomment-318640464
Basically, we need mvn clean verify
to work, in an existing namespace. Are we doing something wrong?
but why not mvn fabric8:deploy verify -D.....
?
Arquillian Cube is supposed to deploy the application, no? I'm pretty sure I'm missing something.
Yes when it is necessary (basically when you want to run your application from IDE or from CLI), basically when you create manually your kubernetes.json
then it has sense to do it. But in this application you are not creating any kubernetes.json
manually, you are letting fabric8 plugin to do it, so it means that you need to run at least one time (until you clean
the project) the maven goal to generate these resources.
What I am saying is that if you want to run your tests from Maven, you don't need that Arquillian deploys anything you can just run mvn fabric8:deploy verify -D.....
and that's all. Why would you need Arquillian does anything?
The other thing which might be more useful might be an integration between fabric8 plugin and arquillian so you can run safely from IDE and from CLI without worrying about calling the plugin first.
But this is a big change overall and I would like to listen comments about it from @bartoszmajsak and @iocanel and @jwendell
@Ladicek if you want we can move the conversation to BJN as well.
So, in the linked repo, if I do mvn clean verify -Popenshift,openshift-it -Dnamespace.use.existing=myproject -Denv.init.enabled=true
, the fabric8:resource
and fabric8:build
goals run and the {kubernetes,openshift}.{json,yml}
files are created long before the test starts. So I expect Arquillian to take them, apply them, run the test, then cleanup.
You ask: why do you want to do this? Well I ask: why not? It's simpler, it's how Maven is typically used, and if I understand the docs correctly, it should work. And it seems it would, but the image stream created by fabric8:build
gets deleted for some reason. Is Arquillian possibly doing some pre-test cleanup?
Oh thanks for the BJN offer, but I'm not very familiar with this issue, so unless you are fine with making it a pair debugging session, it wouldn't work :-)
Exactly we can do this thing you mention but you could do mvn clean fabric8:deploy verify -Popenshift,openshift-it -Dnamespace.use.existing=myproject -Denv.init.enabled=false
and you'll get the same, what I mean is why do you want that Arquillian deploys something generated by Maven plugin when the Maven plugin itself can do it.
Well, at the very least, I don't want to force users to add more commands to the cmdline, when the traditional mvn clean verify
obviously should work.
But out of curiosity, I tried mvn clean fabric8:deploy verify -Popenshift,openshift-it -Dnamespace.use.existing=myproject -Denv.init.enabled=false
on the linked repo, and fabric8:deploy
doesn't even get a chance to run, because tests are executed first.
humm ok then tomorrow morning I will take a look what you should do to make it work and provide you the CLI option to do it.
Thank you!
We have discussed potential solutions for this functionality with @lordofthejars.
To let you guys use one mvn command to run everything we will fix Cube to scan for files generated by fabric8-maven-plugin
. @lordofthejars is on it.
We have two options here if we consider use case when you run the test from the IDE. We need to have those {kubernetes,openshift}.{json,yml}
files generated upfront.
fabric8-maven-plugin
to
@AutogenerateOpenshiftResources
annotation put on the test classShrinkwrap
descriptors so you can either create default files like fmp does but also open it up for customization "shrinkwrap style"
@Deployment
methods we would like to have to make it simple and powerful enoughThoughts?
Re "Quick win": my understanding from this section of the documentation is that Arquillian Cube should already be able to find the FMP-generated files. Am I wrong here? I'd consider this a bugfix, not an improvement. Actually you're using the word "fix" too, so it seems we're on the same page :-)
Re "Desired improvement": I don't think we considered running tests from IDE just yet :-) I think all our Kubernetes/OpenShift tooling revolves around FMP, so the 1st option sounds best to me. But I don't have all the details, I might be easily missing something.
And thanks for paying attention to this, it's gonna be a huge help for us!
Ok, let's make the "Quick win" working then and we can discuss IDE experience when you will be focusing on it. I think we have a bug here which @lordofthejars is looking at.
And thanks for paying attention to this, it's gonna be a huge help for us!
Sure, our pleasure :)
We have found the root cause. Currently fabric8 plugin generate resources at target/classes/META-INF/fabric8
classpath location. The problem is that surefire
plugin does not add target/classes
but target/test-classes
("surefire.test.class.path" -> "/Users/alex/git/rest_springboot-tomcat/target/test-classes:/Users/alex/git/rest_springboot-tomcat/target/spring-boot-http-7-SNAPSHOT.jar:/Users/alex/.m2/repository/org/apache/tomcat/tomcat-juli/8.0.36/tomcat-juli-8.0.36.jar:..."
so for Arquillian is impossible to find these files.
What we are going to do is talk with fabric8 guys to see if the plugin can copy resources in both places.
That sounds weird. Per http://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html, the target/classes
directory is on test classpath. Is that maybe a Surefire/Failsafe bug? Let me check.
Currently you are using failsafe
which should work in same way, but checking all resources loaded debugging the code we saw that the resources of target/classes are not there and also surefire.test.class.path
only contains test-classes
place. Then we moved the generated files there and they were found by Cube.
Failsafe documentation is the same in this regard: http://maven.apache.org/components/surefire/maven-failsafe-plugin/examples/configuring-classpath.html
Documentation is apparently wrong. In the surefire.test.class.path
property, passed to Failsafe Runner, what you are getting is a reference to a jar file with your production code, but not target/classes
. And apparently files generated by fabric8-maven-plugin land in META-INF
after this jar is produced.
Ah, I see! That's again the thing with Failsafe preferring to use the JAR instead of target/classes
!
OK, so if I downgrade to Failsafe 2.18.1, which still uses target/classes
, I get further. The test fails when trying to apply target/spring-boot-http-is.yml
with an error message of:
imagestreams "spring-boot-http" is invalid: spec.tags[latest].from.name: Invalid value: "spring-boot-http@sha256:cf768ac1152974a20a08a34c76066a97137a1f0c29c1d57215dad183b9215b3b
This image did exist before the test started, as it was created by the Fabric8 Maven plugin. I can see it in the OpenShift web console. I don't know who deleted it -- was it Arquillian Cube?
(This finding is consistent with the issue description in https://github.com/openshiftio/appdev-planning/issues/43#issuecomment-318640464)
The problem here is that fabric8 executes this -is.yml
file, and then in cube we are rexecuting again and you get this failure. In fact if you use CLI you'll get the same error. Figuring out how to fix this.
I think you can easily apply the same file twice. The issue seems to be that FMP creates the image, the image stream and the image stream tag, then someone deletes it all, and then Cube tries to apply the -is.yml
file, which tries to create the image stream and the image stream tag, but the image is missing.
Anyway, great we're on the same page! :-)
exactly this is what is happening, now I have commented the code in cube that detects -is.yml
files and it has been able to deploy everything. So this is a really good step forward, so I need to think a bit but maybe we will make this -is.yml
detection code optional being default to false.
cc/ @bartoszmajsak @dipak-pawar
Great! I'm just wondering, who and why deletes the image+imagestream+imagestreamtag? That shouldn't happen, should it?
Also, instead of downgrading to Failsafe 2.18.1, adding this to the Failsafe plugin configuration seems to work:
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.outputDirectory}/META-INF/fabric8</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
Good news I have got a running version of the project. I will add a new flag, and release 1.9.0 version of cube which by default will ignore the -is.yml
files.
Cool! Any idea why the image gets deleted and applying the -is.yml
file subsequently fails? I still don't quite understand why that happens.
I think that it is not really delated at all, for what we have seen is that is trying to create resources twice. Look if you want to try by yourself do this. mvn clean package
and then go to target
directory and do oc create -f ...-is.yml
and you'll get the same error.
Well you're right, oc create -f ...-is.yml
indeed also fails with error generating tag event: imagestreamimage.image.openshift.io "sha256:469b67311d56220795dec3c7a39ef2d9f61cd9d2cc25cca99752fb1cee2a0ebb" not found
. That "not found" bit fooled me.
yes I think that it is more how OpenShift treat this scenario more than something related to our stuff.
So the reason why META-INF/fabric8
stuff couldn't be found on test classpath is this line: https://github.com/snowdrop/spring-boot-http-booster/blob/master/pom.xml#L133 Once removed, it works just fine. (Where just fine = obviously I hit the issue with -is.yml
.)
EDIT: and the reason is simple. With that line, fabric8:resources
runs after the JAR is created, so the META-INF/fabric8
stuff simply wasn't there when the JAR was being created.
I sent PRs to Spring Boot boosters to avoid binding FMP to the package
phase. That should solve our issues with finding META-INF/fabric8
on the test classpath, without actually changing FMP.
Ok I have updated kubernetes client on cube to latest ones, also I have fixed the problem with -is.yml
files. Tomorrow I will release a new version so you can work on Monday.
Thanks @lordofthejars! Oh and I'm totally fine with release on Monday, we all deserve a weekend off of work!
The problem is that Monday is PTO in my case, then Tue and Wed I am at JavaZone so this leave us to Thursday.
Well I can do computers too, so I can take care of the release.
When this is released @Ladicek if you see that it works, could you just ping us so we can close this issue?
Instead of releasing and trying it out only then maybe you could build snapshot against latest master
and confirm if that works for you @Ladicek?
I tried locally and it worked
El 9 sept. 2017 3:16 p. m., "Bartosz Majsak" notifications@github.com escribió:
Instead of releasing and trying it out only then maybe you could build snapshot against latest master and confirm if that works for you @Ladicek https://github.com/ladicek?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arquillian/arquillian-cube/issues/743#issuecomment-328276698, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcmYSGyAhYnmTOk9GqFDkvtzDixyZiLks5sgo-TgaJpZM4OFVmn .
I just tried locally as well and it works. Unless it breaks your schedules or something, I'd like to check a couple more boosters before proceeding with a release. I'll comment later today or tomorrow.
Thanks @Ladicek. Please run more booster tests and let us know so we gonna release being sure it works for you.
Thanks a lot @bartoszmajsak @lordofthejars for looking into this and also @Ladicek for substituting me in this case, unfortunately I wasn't available last week. I'm going try it out and see what happens. @Ladicek has already tried this out with Spring Boot http booster and it worked just fine, so thank you again, you helped us quite a bit ! :)
Just give us go/no-go and we will proceed accordingly :)
Unfortunately, this isn't enough yet :-( It works flawlessly when running tests in an existing project (which is our main usecase), but running in an Arquillian-created project doesn't work (which, obviously, is needed for OpenShift.io).
mvn clean verify -Popenshift,openshift-it -Dnamespace.use.existing=myproject -Denv.init.enabled=true
worksmvn clean verify -Popenshift,openshift-it -Denv.init.enabled=true
doesn't work, the build gets stuck at Applying kubernetes configuration from: jar:file:/home/lthon/tmp/rest_springboot-tomcat/target/spring-boot-http-7-SNAPSHOT.jar!/META-INF/fabric8/openshift.json
, no pod is running in the itest-xxxxx
namespace, presumably because the image was build in another namespace?mvn clean verify -Popenshift,openshift-it -Denv.init.enabled=true -DenableImageStreamDetection=true
doesn't work, the test fails with java.lang.RuntimeException: io.fabric8.kubernetes.clnt.v2_6.KubernetesClientException: Failure executing: POST at: https://192.168.0.100:8443/oapi/v1/namespaces/itest-6785a55b/imagestreams. Message: ImageStream "spring-boot-http" is invalid
, which seems to be the same error message this all started with.Sounds like we're back to square 1?
Issue Overview
I have my existing openshift project which si empty. I want arquillian cube to deploy test resources (e.g. openshift.yml) generated by FMP during resource goal. When running integration tests, arquillian cube throws the following exception about non-existing image stream:
When I run:
It works fine.
Expected Behaviour
Integration test deploys its resources and test them
Current Behaviour
Integration test fails to deploy its resources.
Steps To Reproduce
arquillian-cube-integration-test-openshift
mvn clean verify -Popenshift,openshift-it -Dnamespace.use.existing=my-project -Denv.init.enabled=true