Review Board 1.7.22


SQOOP-1115 Sqoop2: Integration: Provide helper methods for synchronous job submission

Review Request #12202 - Created June 30, 2013 and updated

Jarek Cecho
SQOOP-1115
Reviewers
Sqoop
sqoop-sqoop2
I've abstracted the same copy&pasted code into helper method that will submit the job in synchronous mode.
Both unit and integration tests seems to be passing.
test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
Revision 6aeadd4e54e47e5644270b15813b2d9c4cedc059 New Change
[20] 15 lines
[+20]
16
 * limitations under the License.
16
 * limitations under the License.
17
 */
17
 */
18
package org.apache.sqoop.test.testcases;
18
package org.apache.sqoop.test.testcases;
19

    
   
19

   
20
import org.apache.log4j.Logger;
20
import org.apache.log4j.Logger;

    
   
21
import org.apache.sqoop.client.SubmissionCallback;
21
import org.apache.sqoop.framework.configuration.OutputFormat;
22
import org.apache.sqoop.framework.configuration.OutputFormat;
22
import org.apache.sqoop.framework.configuration.StorageType;
23
import org.apache.sqoop.framework.configuration.StorageType;
23
import org.apache.sqoop.model.MConnection;
24
import org.apache.sqoop.model.MConnection;
24
import org.apache.sqoop.model.MFormList;
25
import org.apache.sqoop.model.MFormList;
25
import org.apache.sqoop.model.MJob;
26
import org.apache.sqoop.model.MJob;
26
import org.apache.sqoop.model.MPersistableEntity;
27
import org.apache.sqoop.model.MPersistableEntity;

    
   
28
import org.apache.sqoop.model.MSubmission;
27
import org.apache.sqoop.test.asserts.ProviderAsserts;
29
import org.apache.sqoop.test.asserts.ProviderAsserts;
28
import org.apache.sqoop.test.data.Cities;
30
import org.apache.sqoop.test.data.Cities;
29
import org.apache.sqoop.test.db.DatabaseProvider;
31
import org.apache.sqoop.test.db.DatabaseProvider;
30
import org.apache.sqoop.test.db.DatabaseProviderFactory;
32
import org.apache.sqoop.test.db.DatabaseProviderFactory;
31
import org.apache.sqoop.validation.Status;
33
import org.apache.sqoop.validation.Status;
[+20] [20] 13 lines
[+20]
45

    
   
47

   
46
  private static final Logger LOG = Logger.getLogger(ConnectorTestCase.class);
48
  private static final Logger LOG = Logger.getLogger(ConnectorTestCase.class);
47

    
   
49

   
48
  protected static DatabaseProvider provider;
50
  protected static DatabaseProvider provider;
49

    
   
51

   

    
   
52
  /**

    
   
53
   * Default submission callbacks that are printing various status about the submission.

    
   
54
   */

    
   
55
  protected static SubmissionCallback DEFAULT_SUBMISSION_CALLBACKS = new SubmissionCallback() {

    
   
56
    @Override

    
   
57
    public void submitted(MSubmission submission) {

    
   
58
      LOG.info("Submission submitted: " + submission);

    
   
59
    }

    
   
60

   

    
   
61
    @Override

    
   
62
    public void updated(MSubmission submission) {

    
   
63
      LOG.info("Submission updated: " + submission);

    
   
64
    }

    
   
65

   

    
   
66
    @Override

    
   
67
    public void finished(MSubmission submission) {

    
   
68
      LOG.info("Submission finished: " + submission);

    
   
69
    }

    
   
70
  };

    
   
71

   
50
  @BeforeClass
72
  @BeforeClass
51
  public static void startProvider() throws Exception {
73
  public static void startProvider() throws Exception {
52
    provider = DatabaseProviderFactory.getProvider(System.getProperties());
74
    provider = DatabaseProviderFactory.getProvider(System.getProperties());
53
    LOG.info("Starting database provider: " + provider.getClass().getName());
75
    LOG.info("Starting database provider: " + provider.getClass().getName());
54
    provider.start();
76
    provider.start();
[+20] [20] 117 lines
[+20] [+] protected void createConnection(MConnection connection) {
172
   */
194
   */
173
 protected void createJob(MJob job) {
195
 protected void createJob(MJob job) {
174
    assertEquals(Status.FINE, getClient().createJob(job));
196
    assertEquals(Status.FINE, getClient().createJob(job));
175
    assertNotSame(MPersistableEntity.PERSISTANCE_ID_DEFAULT, job.getPersistenceId());
197
    assertNotSame(MPersistableEntity.PERSISTANCE_ID_DEFAULT, job.getPersistenceId());
176
  }
198
  }

    
   
199

   

    
   
200
  /**

    
   
201
   * Run job with given jid.

    
   
202
   *

    
   
203
   * @param jid Job id

    
   
204
   * @throws Exception

    
   
205
   */

    
   
206
  protected void runJob(long jid) throws Exception {

    
   
207
    getClient().startSubmission(jid, DEFAULT_SUBMISSION_CALLBACKS, 100);

    
   
208
  }

    
   
209

   

    
   
210
  /**

    
   
211
   * Run given job.

    
   
212
   *

    
   
213
   * @param job Job object

    
   
214
   * @throws Exception

    
   
215
   */

    
   
216
  protected void runJob(MJob job) throws Exception {

    
   
217
    runJob(job.getPersistenceId());

    
   
218
  }
177
}
219
}
test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableExportTest.java
Revision fbf46e997c73ef3282d62820a50c9b6dc303020c New Change
 
test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java
Revision 639d9ad1a37fa6fd577adc2db36ea7b4d63697a2 New Change
 
  1. test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java: Loading...
  2. test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableExportTest.java: Loading...
  3. test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableImportTest.java: Loading...