I'm trying to setup the pig unit tests and I was looking into the documentation which they've provided. It seems a bit outdated so I switched to the svn trunk. The first strange thing is that actually it needs some more libs, not only pigunit, pig and hadoop-commons in order to work(add hadoop-hdfs, hadoop-mapreduce-client-core, hadoop-mapreduce-client-jobclient). I'm not sure that having these in my dependency manager is something good but this is not the main problem. So here's the test I'm trying to execute:
#Test
public void testNtoN() throws ParseException, IOException {
String[] args = {
"n=3",
"reducers=1",
"input=top_queries_input_data.txt",
"output=top_3_queries",
};
test = new PigTest("script dir", args);
String[] output = {
"(yahoo,25)",
"(facebook,15)",
"(twitter,7)",
};
test.assertOutput("queries_limit", output);
}
And here's the actual script:
data =
LOAD '$input'
AS (query:CHARARRAY, count:INT);
queries_group =
GROUP data
BY query
PARALLEL $reducers;
queries_sum =
FOREACH queries_group
GENERATE
group AS query,
SUM(data.count) AS count;
queries_ordered =
ORDER queries_sum
BY count DESC
PARALLEL $reducers;
queries_limit = LIMIT queries_ordered $n;
STORE queries_limit INTO '$output';
Here's the stacktrace:
STORE queries_limit INTO 'top_3_queries';
--> none
org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1066: Unable to open iterator for alias queries_limit
at org.apache.pig.PigServer.openIterator(PigServer.java:1019)
at org.apache.pig.pigunit.PigTest.getAliasFromCache(PigTest.java:224)
at org.apache.pig.pigunit.PigTest.getActualResults(PigTest.java:319)
at org.apache.pig.pigunit.PigTest.assertOutput(PigTest.java:409)
at org.apache.pig.pigunit.PigTest.assertOutput(PigTest.java:400)
at BlaUnitTest.testBla(BlaUnitTest.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.io.IOException: Couldn't retrieve job.
at org.apache.pig.PigServer.store(PigServer.java:1083)
at org.apache.pig.PigServer.openIterator(PigServer.java:994)
... 34 more
I tried to debug it to see what actually happens and this occurs when it tries to build the query plan and acquire the ExecJob but I couldn't figure it out. I even tried to simplify the script and remove everything but the code for loading and storing the data. The result was the same.
I succeeded to resolve the issue. The problem was that I had included some dependencies in the classpath which seems to mess up the correct execution. The only needed dependencies are hadoop-core(I'm using hadoop-aws because I'm using it with aws), hadoop-client, pig and pigunit. So now everything is running correctly.
Related
Trying to access HDFS location using Kerberose authentication, but getting below error message:
java.io.IOException: failure to login
at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:839)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:775)
at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:648)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2859)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2851)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2714)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:382)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:181)
at com.xyz.module.submodule.common.utils.HDFSPropertyLookup.loadProperties(HDFSPropertyLookup.java:75)
at com.xyz.module.submodule.common.utils.HDFSPropertyLookup.initialize(HDFSPropertyLookup.java:37)
at com.xyz.module.submodule.common.utils.HDFSPropertyLookupTest.initializePropertiesFile(HDFSPropertyLookupTest.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: javax.security.auth.login.LoginException: unable to find LoginModule class: com.sun.security.auth.module.UnixLoginModule
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:794)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:813)
... 31 more
Cause: LoginModule class: com.sun.security.auth.module.UnixLoginModule not found.
Want to know in which .jar file com.sun.security.auth.module.UnixLoginModule is present?
If someone might have faced this issue before, then please let help!
This issue got resolved!
Let me share the real cause and how it got resolved?
In unit test code, I was setting the os.name system property value to different operating system for my test case scenario as below:
System.setProperty("os.name", "Windows");
I was setting above properties value with Windows/Unix/MAC etc, but I missed to reset to its original value.
In same project there I was executing FileSystem.get(new Configuration()); from Hadoop API, in which Kerberose authentication was set.
So while execution operating system name was getting changed to some other name and it was not reset to original name.
Solution:
So in setup method I collected the original OS name to some other variable and after all test case completion reset to original name as below:
#BeforeClass
public static void setup() throws IOException {
System.setProperty("os.name.orig", System.getProperty("os.name"));
}
// other test case methods continue...
#AfterClass
public static void clearProperties() throws IOException {
System.setProperty("os.name", System.getProperty("os.name.orig"));
System.clearProperty("os.name.orig");
}
After above setting OS was reverted back to its original name and everything started working properly.
Hope this will help others in future!!!
I am running into an unexpected issue with one of my scripts.
I have a an application that can publish news on a number of different levels such as an organisational level and levels lower down in the organisation. Depending on your occupation only certain people can publish a news article on the org level.
I have written the scripts on this level and they all work.
I copied the scripts and slightly modified them to publish the news at a lower level and this is where I am seemingly running into trouble. One particular script adds an image into the news article and to do that you need to manipulate a series of modal dialog windows. This workflow is identical to the org level.
However when I run the script at the lower level I get an error which states:
java.lang.ArrayIndexOutOfBoundsException: 1
The stacktrace is as follows:
at com.desire2learn.dev.pages.CreateItemNewsPage.get_window_ids(CreateItemNewsPage.java:338)
at com.desire2learn.dev.tests.NewsItemsUnitLevelTest.publish_news_with_image(NewsItemsUnitLevelTest.java:379)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
The code it slips up on is the following:
public void get_window_ids(){
//Get the handles for the main window and the popup window for the upload button
try {
Set<String> AllWindowHandles = driver.getWindowHandles();
System.out.println(AllWindowHandles.size()+ " distinct windows: " + AllWindowHandles);
window1 = (String) AllWindowHandles.toArray()[0];
System.out.println("\nwindow 1 is " + window1+"\n");
window2 = (String) AllWindowHandles.toArray()[1];
System.out.println("\nwindow 2 is " + window2+"\n");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
It trips up on window2.
However this same method works on the org level. I also notice that it says there are 2 distinct windows at org level:
2 distinct windows: [CDwindow-13376ec5-43ac-4668-a2f9-50660e3b09cf,
CDwindow-d3e9e6eb-954a-4bf8-ba28-b30049ed85d8]
Also when I debug on the unit level iget the following:
2 distinct windows: [CDwindow-13376ec5-43ac-4668-a2f9-50660e3b09cf,
CDwindow-d3e9e6eb-954a-4bf8-ba28-b30049ed85d8]
Running the script I get only 1 distinct window however....very strange.
It baffles me. Can someone give me a pointer or am I just doing something stupid here?
UPDATE
I changed a configuration setting in the application which controls whether popups are displayed as modal or nonmodal popups and it seems to resolve the issue. The popup still displays that it is nonModalDialog however. So it appears that nothing has changed. Except the script does not work when the conf item is disabled and works when it is disabled.
Please disregard this question I have resolved it. The issue was with Modal and non modal windows and my script was configured for nonmodal popups. I couldnt see that the scripts I ran in a different part of the application had beed configured for modal dialogs breaking my script in the process.
Appologies for wasting peoples time on this.
I'm having an issue with a JUnit test I made. The method I'm testing takes an InputStream should throw an exception if the passed InputStream doesn't support mark/reset.
The problem I am running into is that my test to ensure an exception gets thrown when an InputStream that doesn't support mark/reset gets passed (posted below) keeps throwing an AccessDeniedException.
public class IOTest{
#Rule
public TemporaryFolder tempFolder = TemporaryFolder()
#Before
public void createFolder() throws IOException {
Files.createDirectories(tempFolder.getRoot().toPath().resolve("testFile"));
}
#Test(expected = IllegalArgumentException.class)
public void testDetectCharsetOnlyAcceptsMarkResetSupportedInputStreams() throws IOException {
final Path testPath = tempFolder.getRoot().toPath().resolve("testFile");
final InputStream testStream = Files.newInputStream(testPath);
IO.detectCharset(testStream);
}
}
I think the problem I'm running into has to do with accessing the temporary folder, but I don't know how to circumvent this.
Here is the stack trace that gets printed when I run this test:
java.lang.Exception: Unexpected exception, expected<java.lang.IllegalArgumentException> but was<java.nio.file.AccessDeniedException>
at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:28)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.nio.file.AccessDeniedException: C:\Users\antho\AppData\Local\Temp\junit4390480127201295432\testFile
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at com.bunnell.anthony.booker.IOTest.testDetectCharsetOnlyAcceptsMarkResetSupportedInputStreams(IOTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19)
... 24 more
I'm guessing it has something to do with permissions and the OS, but I'm just not sure how to get around this problem. If it helps, I'm using Windows 10.
You're trying to read from testFile, which is not a file but a directory; you're creating with
Files.createDirectories(tempFolder.getRoot().toPath().resolve("testFile"));
whose documentation says:
Creates a directory by creating all nonexistent parent directories first.
(emphasis mine)
In order to keep your JUnit tests portable and simple, I would suggest removing the external file dependency entirely.
You can do this in two ways:
Create an InputStream from something internal, like a String or byte array. Here is how with strings
Use a mocking framework, such as Mockito, to create a dummy InputStream that has just enough functionality to confirm that the method works. This would be my preferred strategy, as mocking produces much cleaner tests.
I am working on a Java RMI project and I am trying to begin to test the code I've written and when I run the following code, I get an AssertionError on a line that doesn't even have an assertion statement. I am confused as to how to fix this.
public void basicTest() throws UnknownHostException, RemoteException, AlreadyBoundException, NotBoundException, InterruptedException {
int numBooks = 20;
int copiesPerBook = 5;
int booksPerMember = 4;
// Simulate the server
LibraryServerImpl library = new LibraryServerImpl(numBooks, copiesPerBook, booksPerMember);
LibraryServer stub = (LibraryServer) java.rmi.server.UnicastRemoteObject.exportObject(library, 0);
Registry registry = LocateRegistry.createRegistry(port);
registry.bind(libraryName, stub);
// Simulate the client
Member member = new MemberImpl();
assertNotNull(member.getName()); // Will fail until you implement MemberImpl
Thread t = new Thread(new BasicClient(member));
t.start();
t.join();
}
This is the copied trace:
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertNotNull(Assert.java:712)
at org.junit.Assert.assertNotNull(Assert.java:722)
at PublicTests.basicTest(PublicTests.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Line 56 corresponds to registry.bind(libraryName, stub);
Clearly, this does not make sense, so one of the facts is false.
Fact: you got the above stack trace. --no reason to doubt the truthfulness of this fact.
Fact: PublicTests.java is written by you. --no reason to doubt the truthfulness of this fact.
Fact: line 56 of PublicTests.java corresponds to registry.bind(libraryName, stub). Well, this cannot be true, since according to the stack trace, the failure is detected by a call to org.junit.Assert.assertNotNull(), but the line registry.bind(libraryName, stub) is not an invocation of org.junit.Assert.assertNotNull().
However, further down in your code you do have an invocation of assertNotNull(member.getName()), which means that this must be what is being reported as line 56.
So, what you are looking at is a mismatch in the line number being reported in the stack trace. As user indivisible suggested, please refresh your project, clean your output folder, rebuild all projects, and try again.
We are calling the API to undeploy vApps, during out of hours periods, only to start them up again afterwards.
I get an intermittent error whilst trying to undeploy VApps. (I will give the full stack trace later).
Just to let you know what I am doing, is that I am calling VApp.shutdown() first, which always seems to return success. I sometimes wait a period of upto 10 minutes, before calling the Vapp.undeploy(UndeployPowerActionType.DEFAULT) call. It still more often than not, doesnt work. When I then run it again, it quite often DOES work (and when I check the result, the Vapp is indeed undeployed), or if it still doesn't work, then when I call it again, it does work.
The stack trace looks like the following.. (sometimes the array index is out of range with different numbers, eg -5 or -12 etc etc. Bu the stack trace always looks like the following...)
2014-07-17 13:10:33 ERROR [main] ControlModule:75 - Undeploying resulted in an error
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -2
at com.sun.xml.bind.v2.util.CollisionCheckStack.findDuplicate(CollisionCheckStack.java:133)
at com.sun.xml.bind.v2.util.CollisionCheckStack.push(CollisionCheckStack.java:71)
at com.sun.xml.bind.v2.runtime.XMLSerializer.pushObject(XMLSerializer.java:494)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:609)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:113)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:120)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:149)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:269)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:276)
at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:35)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:472)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:230)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:106)
at com.vmware.vcloud.sdk.JAXBUtil.marshal(JAXBUtil.java:199)
at com.vmware.vcloud.sdk.AbstractVapp.createVappUnDeployParamBody(AbstractVapp.java:299)
at com.vmware.vcloud.sdk.AbstractVapp.undeploy(AbstractVapp.java:318)
at com.ipt.ebsa.skyscape.client.module.ControlModule.controlVApp(ControlModule.java:70)
at com.ipt.ebsa.skyscape.client.manager.VMManager.controlVApp(VMManager.java:294)
at com.ipt.ebsa.skyscape.client.CloudManager.UndeployVApp(CloudManager.java:197)
at com.ipt.ebsa.skyscape.client.RajVAppTest.stopAndUndeployVApp(RajVAppTest.java:178)
at com.ipt.ebsa.skyscape.client.RajVAppTest.testUndeployVApp0(RajVAppTest.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:619)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
2014-07-17 13:10:33 DEBUG [main] ControlModule:77 - Undeploying of vapp 'TEST_RAJ2' complete
2014-07-17 13:10:33 DEBUG [main] VMManager:296 - controlVApp exit
Can someone tell me if I am doing anything wrong? Is it normal practise to just have to retry, and eventually it will work, in order to undeploy my Vapp.
If that is the case, and I do have to keep retrying, I can detect this exception, and if I get it, rety a certain number of times before failing finally and giving up?
Or is there another way to detect whether the Vapp is undeployed or not?
Would calling 'shutdown() rather than undeploy() work better? I think , in my experience, that seems more consistent. However, the resulting vApps in the console are entitled as 'partially running' rather than 'shutdown'. This may well be acceptable, as at the end of the day, we just want our cloud hosting partner to stop charging us for periods when we are not needing the vAPPs. I think shutting down the vAPP might actually achieve this purpose? I would have to check iwth the cloud hosting partner.
Any help is much appreciated.
Thanks,