Skip to content

feat: add new sdk method to update instance home credentials #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ typings/
.yarn-integrity

# dotenv environment variables file
.env
*.env

# next.js build output
Expand Down
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
language: node_js
dist: focal


sudo: false
language: node_js

node_js:
- 14
- 16
- 18

before_install:
- echo -e "machine github.ibm.com\n login $GITHUB_OAUTH_TOKEN" > ~/.netrc
- npm i -g npm@8
- npm --version

Expand Down
120 changes: 79 additions & 41 deletions examples/ibm-analytics-engine-api.v3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// To access additional configuration values, uncomment this line and extract the values from config
// const config = readExternalSources(IbmAnalyticsEngineApiV3.DEFAULT_SERVICE_NAME);

test('Initialize services', async () => {
test('Initialize service', async () => {
// begin-common

ibmAnalyticsEngineApiService = IbmAnalyticsEngineApiV3.newInstance();
Expand All @@ -79,7 +79,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_instance

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_instance_state

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-set_instance_home

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
newHmacAccessKey: 'b9****************************4b',
newHmacSecretKey: 'fa********************************************8a',
};
Expand All @@ -151,6 +151,36 @@ describe('IbmAnalyticsEngineApiV3', () => {
// end-set_instance_home
});

test('updateInstanceHomeCredentials request example', async () => {
consoleLogMock.mockImplementation((output) => {
originalLog(output);
});
consoleWarnMock.mockImplementation((output) => {
// if an error occurs, display the message and then fail the test
originalWarn(output);
expect(true).toBeFalsy();
});

originalLog('updateInstanceHomeCredentials() result:');
// begin-update_instance_home_credentials

const params = {
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
hmacAccessKey: 'b9****************************4b',
hmacSecretKey: 'fa********************************************8a',
};

let res;
try {
res = await ibmAnalyticsEngineApiService.updateInstanceHomeCredentials(params);
console.log(JSON.stringify(res.result, null, 2));
} catch (err) {
console.warn(err);
}

// end-update_instance_home_credentials
});

test('getInstanceDefaultConfigs request example', async () => {
consoleLogMock.mockImplementation((output) => {
originalLog(output);
Expand All @@ -165,7 +195,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_instance_default_configs

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -193,7 +223,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-replace_instance_default_configs

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
body: {
'spark.driver.memory': '8G',
'spark.driver.cores': '2',
Expand Down Expand Up @@ -225,7 +255,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-update_instance_default_configs

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
body: {
'ae.spark.history-server.cores': '1',
'ae.spark.history-server.memory': '4G',
Expand Down Expand Up @@ -257,7 +287,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_instance_default_runtime

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -285,7 +315,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-replace_instance_default_runtime

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
sparkVersion: '3.3',
};

Expand Down Expand Up @@ -313,15 +343,23 @@ describe('IbmAnalyticsEngineApiV3', () => {
originalLog('createApplication() result:');
// begin-create_application

// Request models needed by this operation.

// Runtime
const runtimeModel = {
spark_version: '3.3',
};

// ApplicationRequestApplicationDetails
const applicationRequestApplicationDetailsModel = {
application: '/opt/ibm/spark/examples/src/main/python/wordcount.py',
runtime: runtimeModel,
arguments: ['/opt/ibm/spark/examples/src/main/resources/people.txt'],
};

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
applicationDetails: {
application: '/opt/ibm/spark/examples/src/main/python/wordcount.py',
arguments: ['/opt/ibm/spark/examples/src/main/resources/people.txt'],
},
runtime: {
spark_version: '3.1',
},
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
applicationDetails: applicationRequestApplicationDetailsModel,
};

let res;
Expand Down Expand Up @@ -349,7 +387,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-list_applications

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
state: ['accepted', 'running', 'finished', 'failed'],
};

Expand Down Expand Up @@ -378,8 +416,8 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_application

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
applicationId: 'db933645-0b68-4dcb-80d8-7b71a6c8e542',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
applicationId: 'ff48cc19-0e7e-4627-aac6-0b4ad080397b',
};

let res;
Expand Down Expand Up @@ -407,8 +445,8 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_application_state

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
applicationId: 'db933645-0b68-4dcb-80d8-7b71a6c8e542',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
applicationId: 'ff48cc19-0e7e-4627-aac6-0b4ad080397b',
};

let res;
Expand Down Expand Up @@ -436,7 +474,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_current_resource_consumption

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -464,7 +502,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_resource_consumption_limits

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -492,7 +530,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-replace_log_forwarding_config

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
enabled: true,
};

Expand Down Expand Up @@ -521,7 +559,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_log_forwarding_config

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -549,7 +587,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-configure_platform_logging

const params = {
instanceGuid: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceGuid: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
enable: true,
};

Expand Down Expand Up @@ -578,7 +616,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_logging_configuration

const params = {
instanceGuid: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceGuid: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -606,7 +644,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-start_spark_history_server

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand Down Expand Up @@ -634,7 +672,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// begin-get_spark_history_server

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

let res;
Expand All @@ -648,7 +686,7 @@ describe('IbmAnalyticsEngineApiV3', () => {
// end-get_spark_history_server
});

test('stopSparkHistoryServer request example', async () => {
test('deleteApplication request example', async () => {
consoleLogMock.mockImplementation((output) => {
originalLog(output);
});
Expand All @@ -658,22 +696,23 @@ describe('IbmAnalyticsEngineApiV3', () => {
expect(true).toBeFalsy();
});

// begin-stop_spark_history_server
// begin-delete_application

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
applicationId: 'ff48cc19-0e7e-4627-aac6-0b4ad080397b',
};

try {
await ibmAnalyticsEngineApiService.stopSparkHistoryServer(params);
await ibmAnalyticsEngineApiService.deleteApplication(params);
} catch (err) {
console.warn(err);
}

// end-stop_spark_history_server
// end-delete_application
});

test('deleteApplication request example', async () => {
test('stopSparkHistoryServer request example', async () => {
consoleLogMock.mockImplementation((output) => {
originalLog(output);
});
Expand All @@ -683,19 +722,18 @@ describe('IbmAnalyticsEngineApiV3', () => {
expect(true).toBeFalsy();
});

// begin-delete_application
// begin-stop_spark_history_server

const params = {
instanceId: 'dc0e9889-eab2-4t9e-9441-566209499546',
applicationId: 'db933645-0b68-4dcb-80d8-7b71a6c8e542',
instanceId: 'e64c907a-e82f-46fd-addc-ccfafbd28b09',
};

try {
await ibmAnalyticsEngineApiService.deleteApplication(params);
await ibmAnalyticsEngineApiService.stopSparkHistoryServer(params);
} catch (err) {
console.warn(err);
}

// end-delete_application
// end-stop_spark_history_server
});
});
Loading