You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by of...@apache.org on 2020/10/08 14:23:39 UTC
[incubator-datalab] branch develop updated: [DATALAB-2028]
Implemented possibility to turn on billing after DataLab deployment
This is an automated email from the ASF dual-hosted git repository.
ofuks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
The following commit(s) were added to refs/heads/develop by this push:
new 9cef997 [DATALAB-2028] Implemented possibility to turn on billing after DataLab deployment
9cef997 is described below
commit 9cef997d41b9de31727b1d3fa33e14985d5bca83
Author: Oleh Fuks <ol...@gmail.com>
AuthorDate: Thu Oct 8 17:23:04 2020 +0300
[DATALAB-2028] Implemented possibility to turn on billing after DataLab deployment
---
services/self-service/self-service.yml | 1 +
.../conf/SelfServiceApplicationConfiguration.java | 7 +++++++
.../backendapi/service/impl/BillingServiceImpl.java | 6 +++---
.../service/impl/BillingServiceImplTest.java | 19 ++++++++++++-------
4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/services/self-service/self-service.yml b/services/self-service/self-service.yml
index 0e31a5e..1ef10a5 100644
--- a/services/self-service/self-service.yml
+++ b/services/self-service/self-service.yml
@@ -50,6 +50,7 @@ roleDefaultAccess: false
# Set to true to enable the scheduler of billing report.
billingSchedulerEnabled: false
+billingPort: 8088
# Set to true to enable audit
auditEnabled: true
# Name of configuration file for billing report.
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/conf/SelfServiceApplicationConfiguration.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/conf/SelfServiceApplicationConfiguration.java
index 4aaff96..9bdde34 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/conf/SelfServiceApplicationConfiguration.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/conf/SelfServiceApplicationConfiguration.java
@@ -79,6 +79,9 @@ public class SelfServiceApplicationConfiguration extends ServiceConfiguration {
private boolean billingSchedulerEnabled = false;
@JsonProperty
+ private int billingPort;
+
+ @JsonProperty
private boolean auditEnabled = false;
@NotEmpty
@@ -205,6 +208,10 @@ public class SelfServiceApplicationConfiguration extends ServiceConfiguration {
return billingSchedulerEnabled;
}
+ public int getBillingPort() {
+ return billingPort;
+ }
+
public boolean isAuditEnabled() {
return auditEnabled;
}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java
index ef8e379..9826869 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java
@@ -311,9 +311,9 @@ public class BillingServiceImpl implements BillingService {
throw new DatalabException("Wrong URI syntax");
}
return new URIBuilder()
- .setScheme(uri.getScheme())
- .setHost(uri.getHost())
- .setPort(8088)
+ .setScheme(uri.getScheme())
+ .setHost(uri.getHost())
+ .setPort(configuration.getBillingPort())
.setPath(path)
.toString();
}
diff --git a/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/BillingServiceImplTest.java b/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/BillingServiceImplTest.java
index 217e257..67ff768 100644
--- a/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/BillingServiceImplTest.java
+++ b/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/BillingServiceImplTest.java
@@ -116,6 +116,7 @@ public class BillingServiceImplTest extends TestBase {
private static final String COMPUTE_SLAVE_2_VOLUME_PRIMARY_ID = COMPUTE_ID + "-s2" + "-volume-primary";
private static final String COMPUTE_SLAVE_2_VOLUME_SECONDARY_ID = COMPUTE_ID + "-s2" + "-volume-secondary";
private static final String IMAGE_ID = SERVICE_BASE_NAME + "-" + PROJECT + "-" + ENDPOINT + "-" + IMAGE_APPLICATION + "-" + IMAGE_NAME;
+ private static final Integer BILLING_PORT = 8088;
@Mock
private SelfServiceApplicationConfiguration configuration;
@@ -209,8 +210,9 @@ public class BillingServiceImplTest extends TestBase {
@Test
public void updateGCPRemoteBillingData() {
- when(configuration.getServiceBaseName()).thenReturn(SERVICE_BASE_NAME);
- when(configuration.getMaxSparkInstanceCount()).thenReturn(2);
+ when(configuration.getServiceBaseName()).thenReturn(SERVICE_BASE_NAME);
+ when(configuration.getBillingPort()).thenReturn(BILLING_PORT);
+ when(configuration.getMaxSparkInstanceCount()).thenReturn(2);
when(endpointService.getEndpoints()).thenReturn(getGCPEndpointDTO());
when(provisioningService.get(anyString(), anyString(), any(GenericType.class))).thenReturn(getBillingData());
when(projectService.getProjects()).thenReturn(getProjectDTOs());
@@ -232,8 +234,9 @@ public class BillingServiceImplTest extends TestBase {
@Test
public void updateAWSRemoteBillingData() {
- when(configuration.getServiceBaseName()).thenReturn(SERVICE_BASE_NAME);
- when(configuration.getMaxSparkInstanceCount()).thenReturn(2);
+ when(configuration.getServiceBaseName()).thenReturn(SERVICE_BASE_NAME);
+ when(configuration.getBillingPort()).thenReturn(BILLING_PORT);
+ when(configuration.getMaxSparkInstanceCount()).thenReturn(2);
when(endpointService.getEndpoints()).thenReturn(getAWSEndpointDTO());
when(provisioningService.get(anyString(), anyString(), any(GenericType.class))).thenReturn(getBillingData());
when(projectService.getProjects()).thenReturn(getProjectDTOs());
@@ -255,8 +258,9 @@ public class BillingServiceImplTest extends TestBase {
@Test
public void updateAzureRemoteBillingData() {
- when(configuration.getServiceBaseName()).thenReturn(SERVICE_BASE_NAME);
- when(configuration.getMaxSparkInstanceCount()).thenReturn(2);
+ when(configuration.getServiceBaseName()).thenReturn(SERVICE_BASE_NAME);
+ when(configuration.getBillingPort()).thenReturn(BILLING_PORT);
+ when(configuration.getMaxSparkInstanceCount()).thenReturn(2);
when(endpointService.getEndpoints()).thenReturn(getAzureEndpointDTO());
when(provisioningService.get(anyString(), anyString(), any(GenericType.class))).thenReturn(getBillingData());
when(projectService.getProjects()).thenReturn(getProjectDTOs());
@@ -284,7 +288,8 @@ public class BillingServiceImplTest extends TestBase {
@Test
public void updateRemoteBillingDataWithException2() {
- when(endpointService.getEndpoints()).thenReturn(getAWSEndpointDTO());
+ when(configuration.getBillingPort()).thenReturn(BILLING_PORT);
+ when(endpointService.getEndpoints()).thenReturn(getAWSEndpointDTO());
when(provisioningService.get(anyString(), anyString(), any(GenericType.class))).thenThrow(new DatalabException("Exception message"));
billingService.updateRemoteBillingData(getUserInfo());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org