18
18
'use strict' ;
19
19
const IbmAnalyticsEngineApiV3 = require ( '../../dist/ibm-analytics-engine-api/v3' ) ;
20
20
const { readExternalSources } = require ( 'ibm-cloud-sdk-core' ) ;
21
- const authHelper = require ( '../resources/auth-helper.js' ) ;
22
- const describe = authHelper . describe ; // this runs describe.skip if there is no auth.js file :)
21
+ // const authHelper = require('../resources/auth-helper.js');
22
+ const authHelper = require ( '../resources/auth.js' ) ;
23
+ // const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
23
24
// testcase timeout value (200s).
24
25
const timeout = 200000 ;
25
-
26
+ const { IamAuthenticator } = require ( '../../dist/auth' ) ;
26
27
// Location of our config file.
27
- const configFile = 'ibm_analytics_engine_api_v3.env' ;
28
+ // const configFile = 'ibm_analytics_engine_api_v3.env';
28
29
29
- //describe = authHelper.prepareTests(configFile);
30
+ // describe = authHelper.prepareTests(configFile);
30
31
31
32
describe ( 'IbmAnalyticsEngineApiV3_integration' , ( ) => {
32
- const ibmAnalyticsEngineApiService = IbmAnalyticsEngineApiV3 . newInstance ( { } ) ;
33
+ const options = authHelper . ibm_analytics_engine_api_v3 ;
34
+ options . authenticator = new IamAuthenticator ( { apikey : options . apikey } ) ;
35
+ const instanceGuid = options . instance_guid ;
36
+ let applicationId = '' ;
37
+ const ibmAnalyticsEngineApiService = IbmAnalyticsEngineApiV3 . newInstance ( options ) ;
33
38
34
39
expect ( ibmAnalyticsEngineApiService ) . not . toBeNull ( ) ;
35
40
36
41
const config = readExternalSources ( IbmAnalyticsEngineApiV3 . DEFAULT_SERVICE_NAME ) ;
37
42
expect ( config ) . not . toBeNull ( ) ;
38
43
39
44
jest . setTimeout ( timeout ) ;
40
-
41
45
test ( 'getInstanceById()' , async ( ) => {
42
46
const params = {
43
- instanceId : 'testString' ,
47
+ instanceId : instanceGuid ,
44
48
} ;
45
-
46
49
const res = await ibmAnalyticsEngineApiService . getInstanceById ( params ) ;
47
50
expect ( res ) . toBeDefined ( ) ;
48
51
expect ( res . result ) . toBeDefined ( ) ;
@@ -52,25 +55,23 @@ describe('IbmAnalyticsEngineApiV3_integration', () => {
52
55
53
56
// ApplicationRequestApplicationDetails
54
57
const applicationRequestApplicationDetailsModel = {
55
- application : 'testString' ,
56
- class : 'testString' ,
57
- application_arguments : [ 'testString' ] ,
58
- conf : { 'key1' : 'testString' } ,
59
- env : { 'key1' : 'testString' } ,
58
+ application : '/opt/ibm/spark/examples/src/main/python/wordcount.py' ,
59
+ application_arguments : [ '/opt/ibm/spark/examples/src/main/resources/people.txt' ] ,
60
60
} ;
61
61
62
62
const params = {
63
- instanceId : 'testString' ,
63
+ instanceId : instanceGuid ,
64
64
applicationDetails : applicationRequestApplicationDetailsModel ,
65
65
} ;
66
66
67
67
const res = await ibmAnalyticsEngineApiService . createApplication ( params ) ;
68
+ applicationId = res . result . application_id ;
68
69
expect ( res ) . toBeDefined ( ) ;
69
70
expect ( res . result ) . toBeDefined ( ) ;
70
71
} ) ;
71
72
test ( 'getApplications()' , async ( ) => {
72
73
const params = {
73
- instanceId : 'testString' ,
74
+ instanceId : instanceGuid ,
74
75
} ;
75
76
76
77
const res = await ibmAnalyticsEngineApiService . getApplications ( params ) ;
@@ -79,8 +80,8 @@ describe('IbmAnalyticsEngineApiV3_integration', () => {
79
80
} ) ;
80
81
test ( 'getApplicationById()' , async ( ) => {
81
82
const params = {
82
- instanceId : 'testString' ,
83
- applicationId : 'testString' ,
83
+ instanceId : instanceGuid ,
84
+ applicationId : applicationId ,
84
85
} ;
85
86
86
87
const res = await ibmAnalyticsEngineApiService . getApplicationById ( params ) ;
@@ -89,8 +90,8 @@ describe('IbmAnalyticsEngineApiV3_integration', () => {
89
90
} ) ;
90
91
test ( 'getApplicationState()' , async ( ) => {
91
92
const params = {
92
- instanceId : 'testString' ,
93
- applicationId : 'testString' ,
93
+ instanceId : instanceGuid ,
94
+ applicationId : applicationId ,
94
95
} ;
95
96
96
97
const res = await ibmAnalyticsEngineApiService . getApplicationState ( params ) ;
@@ -99,8 +100,8 @@ describe('IbmAnalyticsEngineApiV3_integration', () => {
99
100
} ) ;
100
101
test ( 'deleteApplicationById()' , async ( ) => {
101
102
const params = {
102
- instanceId : 'testString' ,
103
- applicationId : 'testString' ,
103
+ instanceId : instanceGuid ,
104
+ applicationId : applicationId ,
104
105
} ;
105
106
106
107
const res = await ibmAnalyticsEngineApiService . deleteApplicationById ( params ) ;
0 commit comments