Skip to content

Commit

Permalink
LR-521 Merging from Release 5.2.0 to master (#1166)
Browse files Browse the repository at this point in the history
* feat: ED-1175 Standalone helm chart for Learner service (#1159)

* Issue #LR-101 feat: Moved cassandra.cql to sunbird-utils repo as V1.0_cassandra.cql in cassandra-migration module. And removing sunbirdplugin references. (#1161)

* LR-329 - Test Automation for CSP (#1160)
---------

Signed-off-by: Keshav Prasad <[email protected]>
Co-authored-by: Keshav Prasad <[email protected]>
Co-authored-by: Anil Gupta <[email protected]>
Co-authored-by: Bharathwaj <[email protected]>
  • Loading branch information
4 people authored Apr 17, 2023
1 parent 824e455 commit 32dc262
Show file tree
Hide file tree
Showing 28 changed files with 2,629 additions and 600 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["helm-sub-chart"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ RUNNING_PID
/.target/
/bin/
/logs
.vscode
14 changes: 0 additions & 14 deletions core/es-utils/src/main/resources/elasticsearch.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@
"type" = "_doc"
}
},
sunbirdplugin = {
announcementtype = {
index = "announcementtype",
"type" = "_doc"
},
announcement = {
index = "announcement",
"type" = "_doc"
},
metrics = {
index = "metrics",
"type" = "_doc"
}
},
sbtestindex = {
sbtesttype = {
index = "sbtestindex",
Expand Down
2 changes: 1 addition & 1 deletion core/platform-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>cloud-store-sdk</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public static String upload(
public static String getSignedUrl(
String storageType, String container, String objectKey) {
IStorageService storageService = getStorageService(storageType);
return getSignedUrl(storageService, container, objectKey);
return getSignedUrl(storageService, container, objectKey,storageType);
}

public static String getSignedUrl(
IStorageService storageService,
String container,
String objectKey) {
String objectKey,String cloudType) {
int timeoutInSeconds = getTimeoutInSeconds();
return storageService.getSignedURL(
container, objectKey, Some.apply(timeoutInSeconds), Some.apply("r"));
return storageService.getSignedURLV2(
container, objectKey, Some.apply(timeoutInSeconds), Some.apply("r"), Some.apply("application/pdf"));
}

private static IStorageService getStorageService(String storageType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sunbird_otp_allowed_attempt=2
#Telemetry producer related info
telemetry_pdata_id=local.sunbird.learning.service
telemetry_pdata_pid=learning-service
telemetry_pdata_ver=5.1.0
telemetry_pdata_ver=5.2.0
#elastic search top n result count for telemetry
searchTopN=5
ekstep.channel.update.api.url=/channel/v3/update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,33 @@
import static org.powermock.api.mockito.PowerMockito.when;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.sunbird.cloud.storage.BaseStorageService;
import org.sunbird.cloud.storage.factory.StorageServiceFactory;
import org.sunbird.keys.JsonKey;
import scala.Option;

@RunWith(PowerMockRunner.class)
@PowerMockIgnore({
"javax.management.*",
"javax.net.ssl.*",
"javax.security.*",
"jdk.internal.reflect.*"
"javax.management.*",
"javax.net.ssl.*",
"javax.security.*",
"jdk.internal.reflect.*"
})
@PrepareForTest({StorageServiceFactory.class, CloudStorageUtil.class, PropertiesCache.class})
public class CloudStorageUtilTest {

private static final String SIGNED_URL = "singedUrl";
private static final String UPLOAD_URL = "uploadUrl";
private static final String PUT_SIGNED_URL = "gcpSignedUrl";

@Before
public void initTest() {
PowerMockito.mockStatic(PropertiesCache.class);
PropertiesCache propertiesCache = mock(PropertiesCache.class);
when(PropertiesCache.getInstance()).thenReturn(propertiesCache);
PowerMockito.when(propertiesCache.getProperty(Mockito.anyString())).thenReturn("anyString");

BaseStorageService service = mock(BaseStorageService.class);
mockStatic(StorageServiceFactory.class);

Expand All @@ -52,32 +47,74 @@ public void initTest() {
Mockito.any(Option.class),
Mockito.any(Option.class),
Mockito.any(Option.class)))
.thenReturn(UPLOAD_URL);
.thenReturn(UPLOAD_URL);

when(service.getSignedURL(
Mockito.anyString(),
Mockito.anyString(),
Mockito.any(Option.class),
Mockito.any(Option.class)))
.thenReturn(SIGNED_URL);
.thenReturn(SIGNED_URL);

when(service.getPutSignedURL(
Mockito.anyString(),
Mockito.anyString(),
Mockito.any(Option.class),
Mockito.any(Option.class),
Mockito.any(Option.class)))
.thenReturn(PUT_SIGNED_URL);

when(service.getSignedURLV2(
Mockito.eq("azurecontainer"),
Mockito.anyString(),
Mockito.any(Option.class),
Mockito.any(Option.class),
Mockito.any(Option.class)))
.thenReturn(SIGNED_URL);

when(service.getSignedURLV2(
Mockito.eq("gcpcontainer"),
Mockito.anyString(),
Mockito.any(Option.class),
Mockito.any(Option.class),
Mockito.any(Option.class)))
.thenReturn(PUT_SIGNED_URL);

when(service.getSignedURLV2(
Mockito.eq("awscontainer"),
Mockito.anyString(),
Mockito.any(Option.class),
Mockito.any(Option.class),
Mockito.any(Option.class)))
.thenReturn(SIGNED_URL);

} catch (Exception e) {
Assert.fail(e.getMessage());
}
}

@Test
// @Ignore
public void testUploadSuccess() {
String result =
CloudStorageUtil.upload("azure", "container", "key", "/file/path");
CloudStorageUtil.upload("azure", "container", "key", "/file/path");
assertTrue(UPLOAD_URL.equals(result));
}

@Test
@Ignore
public void testGetSignedUrlSuccess() {
String signedUrl = CloudStorageUtil.getSignedUrl("azure", "container", "key");
public void testGetSignedUrlAZURESuccess() {
String signedUrl = CloudStorageUtil.getSignedUrl("azure", "azurecontainer", "key");
assertTrue(SIGNED_URL.equals(signedUrl));
}

@Test
public void testGetSignedUrlGCPSuccess() {
String signedUrl = CloudStorageUtil.getSignedUrl("gcloud", "gcpcontainer", "key");
assertTrue(PUT_SIGNED_URL.equals(signedUrl));
}

@Test
public void testGetSignedUrlAWSSuccess() {
String signedUrl = CloudStorageUtil.getSignedUrl("aws", "awscontainer", "key");
assertTrue(SIGNED_URL.equals(signedUrl));
}
}
24 changes: 24 additions & 0 deletions helm/learner/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
*_test.rego
9 changes: 9 additions & 0 deletions helm/learner/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: common_opa_policies
repository: https://keshavprasadms.github.io/sunbird-helmchart-templates
version: 0.1.0
- name: learner_opa_policies
repository: https://keshavprasadms.github.io/sunbird-lms-service
version: 0.1.0
digest: sha256:1d739f27fd24f4b32e2b3c2438886d369107bd65c85b99ef9151a0b6ae51b63a
generated: "2023-02-19T08:47:55.332813+05:30"
32 changes: 32 additions & 0 deletions helm/learner/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v2
name: learner
description: A helm chart for learner service

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "5.0.0"

dependencies:
- name: common_opa_policies
repository: https://keshavprasadms.github.io/sunbird-helmchart-templates
version: 0.1.0
- name: learner_opa_policies
repository: https://keshavprasadms.github.io/sunbird-lms-service
version: 0.1.0
Binary file added helm/learner/charts/common_opa_policies-0.1.0.tgz
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 32dc262

Please sign in to comment.