Search in sources :

Example 1 with OozieCLI

use of org.apache.oozie.cli.OozieCLI in project oozie by apache.

the class TestAuthFilterAuthOozieClient method testClientAuthMethod.

/**
 * Test authentication
 */
public void testClientAuthMethod() throws Exception {
    runTest(new Callable<Void>() {

        public Void call() throws Exception {
            String oozieUrl = getContextURL();
            String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl, "-auth", "SIMPLE" };
            assertEquals(0, new OozieCLI().run(args));
            return null;
        }
    }, null);
    // bad method
    runTest(new Callable<Void>() {

        public Void call() throws Exception {
            String oozieUrl = getContextURL();
            String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl, "-auth", "fake" };
            assertEquals(-1, new OozieCLI().run(args));
            return null;
        }
    }, null);
}
Also used : OozieCLI(org.apache.oozie.cli.OozieCLI) AuthenticationException(org.apache.hadoop.security.authentication.client.AuthenticationException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 2 with OozieCLI

use of org.apache.oozie.cli.OozieCLI in project oozie by apache.

the class TestAuthFilterAuthOozieClient method testClientWithAnonymous.

public void testClientWithAnonymous() throws Exception {
    Configuration conf = new Configuration(false);
    conf.set("oozie.authentication.simple.anonymous.allowed", "true");
    runTest(new Callable<Void>() {

        public Void call() throws Exception {
            String oozieUrl = getContextURL();
            String[] args = new String[] { "admin", "-status", "-oozie", oozieUrl };
            assertEquals(0, new OozieCLI().run(args));
            return null;
        }
    }, conf);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) OozieCLI(org.apache.oozie.cli.OozieCLI) AuthenticationException(org.apache.hadoop.security.authentication.client.AuthenticationException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 3 with OozieCLI

use of org.apache.oozie.cli.OozieCLI in project oozie by apache.

the class TestOozieCLI method testNoRetryForError.

public void testNoRetryForError() throws Exception {
    runTest(END_POINTS, SERVLET_CLASSES, false, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            HeaderTestingVersionServlet.OOZIE_HEADERS.clear();
            String oozieUrl = getContextURL();
            String[] args = new String[] { "job", "-info", "aaa", "-oozie", oozieUrl, "-debug" };
            OozieCLI cli = new OozieCLI();
            CLIParser parser = cli.getCLIParser();
            try {
                final CLIParser.Command command = parser.parse(args);
                cli.processCommand(parser, command);
            } catch (Exception e) {
                // Create connection will be successful, no retry
                assertFalse(e.getMessage().contains("Error while connecting Oozie server"));
                assertTrue(e.getMessage().contains("invalid job id [aaa]"));
            }
            return null;
        }
    });
}
Also used : CLIParser(org.apache.oozie.cli.CLIParser) OozieCLI(org.apache.oozie.cli.OozieCLI)

Example 4 with OozieCLI

use of org.apache.oozie.cli.OozieCLI in project oozie by apache.

the class TestOozieCLI method runOozieCLIAndGetStdout.

private String runOozieCLIAndGetStdout(String[] args) {
    PrintStream original = System.out;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    String outStr = null;
    System.out.flush();
    try {
        System.setOut(ps);
        assertEquals(0, new OozieCLI().run(args));
        System.out.flush();
        outStr = baos.toString();
    } finally {
        System.setOut(original);
        if (outStr != null) {
            System.out.print(outStr);
        }
        System.out.flush();
    }
    return outStr;
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OozieCLI(org.apache.oozie.cli.OozieCLI)

Example 5 with OozieCLI

use of org.apache.oozie.cli.OozieCLI in project oozie by apache.

the class TestOozieCLI method runOozieCLIAndGetStderr.

private String runOozieCLIAndGetStderr(String[] args) {
    PrintStream original = System.err;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    String outStr = null;
    System.err.flush();
    try {
        System.setErr(ps);
        assertEquals(-1, new OozieCLI().run(args));
        System.err.flush();
        outStr = baos.toString();
    } finally {
        System.setErr(original);
        if (outStr != null) {
            System.err.print(outStr);
        }
        System.err.flush();
    }
    return outStr;
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OozieCLI(org.apache.oozie.cli.OozieCLI)

Aggregations

OozieCLI (org.apache.oozie.cli.OozieCLI)9 IOException (java.io.IOException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 AuthenticationException (org.apache.hadoop.security.authentication.client.AuthenticationException)5 Configuration (org.apache.hadoop.conf.Configuration)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintStream (java.io.PrintStream)2 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 Path (org.apache.hadoop.fs.Path)1 CLIParser (org.apache.oozie.cli.CLIParser)1