Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Data Flow
Data Ingestion
Ingestion Workflow
Commits
88cd2161
Commit
88cd2161
authored
Nov 18, 2020
by
Kishore Battula
Browse files
Merge branch 'new-workflow-apis' into h2-ingestion
parents
1061d4f7
2b372acd
Pipeline
#16244
failed with stages
in 4 minutes and 4 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/fileshare/FileShareClientFactory.java
deleted
100644 → 0
View file @
1061d4f7
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
import
com.azure.storage.file.share.ShareClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Component
public
class
FileShareClientFactory
implements
IFileShareClientFactory
{
@Autowired
private
ShareClient
client
;
@Override
public
ShareClient
getClient
()
{
return
this
.
client
;
}
}
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/fileshare/FileShareConfig.java
View file @
88cd2161
...
@@ -11,4 +11,5 @@ import org.springframework.context.annotation.Configuration;
...
@@ -11,4 +11,5 @@ import org.springframework.context.annotation.Configuration;
@Setter
@Setter
public
class
FileShareConfig
{
public
class
FileShareConfig
{
private
String
shareName
;
private
String
shareName
;
private
String
dagsFolder
;
}
}
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/fileshare/FileShareStore.java
View file @
88cd2161
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
import
com.azure.storage.file.share.ShareClient
;
import
com.azure.storage.file.share.ShareDirectoryClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
@Component
public
class
FileShareStore
{
public
class
FileShareStore
{
@Autowired
private
ShareDirectoryClient
directoryClient
;
private
IFileShareClientFactory
fileShareClientFactory
;
public
FileShareStore
(
final
ShareDirectoryClient
directoryClient
)
{
this
.
directoryClient
=
directoryClient
;
}
public
void
createFile
(
final
String
contents
,
final
String
name
)
{
public
void
createFile
(
final
String
contents
,
final
String
name
)
{
getShare
Client
()
.
createFile
(
name
,
contents
.
getBytes
().
length
)
directory
Client
.
createFile
(
name
,
contents
.
getBytes
().
length
)
.
upload
(
new
ByteArrayInputStream
(
contents
.
getBytes
()),
contents
.
getBytes
().
length
);
.
upload
(
new
ByteArrayInputStream
(
contents
.
getBytes
()),
contents
.
getBytes
().
length
);
}
}
private
ShareClient
getShareClient
()
{
return
this
.
fileShareClientFactory
.
getClient
();
}
}
}
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/fileshare/FileShareStoreProvider.java
0 → 100644
View file @
88cd2161
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
import
com.azure.storage.file.share.ShareClient
;
import
com.azure.storage.file.share.ShareDirectoryClient
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
FileShareStoreProvider
{
@Bean
@Qualifier
(
"dags"
)
public
FileShareStore
buildDagsStore
(
ShareClient
shareClient
,
FileShareConfig
config
)
{
ShareDirectoryClient
client
=
shareClient
.
getDirectoryClient
(
config
.
getDagsFolder
());
return
new
FileShareStore
(
client
);
}
}
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/fileshare/IFileShareClientFactory.java
deleted
100644 → 0
View file @
1061d4f7
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
import
com.azure.storage.file.share.ShareClient
;
public
interface
IFileShareClientFactory
{
ShareClient
getClient
();
}
provider/workflow-azure/src/main/java/org/opengroup/osdu/workflow/provider/azure/repository/WorkflowDefinitionRepository.java
View file @
88cd2161
...
@@ -3,11 +3,13 @@ package org.opengroup.osdu.workflow.provider.azure.repository;
...
@@ -3,11 +3,13 @@ package org.opengroup.osdu.workflow.provider.azure.repository;
import
org.opengroup.osdu.workflow.provider.azure.fileshare.FileShareStore
;
import
org.opengroup.osdu.workflow.provider.azure.fileshare.FileShareStore
;
import
org.opengroup.osdu.workflow.provider.interfaces.IWorkflowDefinitionRepository
;
import
org.opengroup.osdu.workflow.provider.interfaces.IWorkflowDefinitionRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
@Component
@Component
public
class
WorkflowDefinitionRepository
implements
IWorkflowDefinitionRepository
{
public
class
WorkflowDefinitionRepository
implements
IWorkflowDefinitionRepository
{
@Autowired
@Autowired
@Qualifier
(
"dags"
)
private
FileShareStore
fileShareStore
;
private
FileShareStore
fileShareStore
;
@Override
@Override
...
...
provider/workflow-azure/src/main/resources/application.properties
View file @
88cd2161
...
@@ -13,13 +13,13 @@
...
@@ -13,13 +13,13 @@
# limitations under the License.
# limitations under the License.
# Application name
# Application name
spring.application.name
=
workflow
spring.application.name
=
workflow
-azure
LOG_PREFIX
=
workflow
LOG_PREFIX
=
workflow
# Server Path Configuration
# Server Path Configuration
server.servlet.contextPath
=
/api/workflow/v1/
server.servlet.contextPath
=
/api/workflow/v1/
# Istio Auth Config Toggle
# Istio Auth Config Toggle
azure.istio.auth.enabled
=
${azure_istioauth_enabled}
azure.istio.auth.enabled
=
${azure_istioauth_enabled}
# Partition service
# Partition service
...
@@ -41,13 +41,13 @@ osdu.azure.cosmosdb.workflowRunCollection=WorkflowRun
...
@@ -41,13 +41,13 @@ osdu.azure.cosmosdb.workflowRunCollection=WorkflowRun
# Azure fileshare configuration
# Azure fileshare configuration
osdu.azure.fileshare.shareName
=
airflowdags
osdu.azure.fileshare.shareName
=
airflowdags
osdu.azure.fileshare.dagsFolder
=
dags
# Azure KeyVault configuration
# Azure KeyVault configuration
azure.keyvault.url
=
${KEYVAULT_URI}
azure.keyvault.url
=
${KEYVAULT_URI}
# Azure App Insights configuration
# Azure App Insights configuration
azure.application-insights.instrumentation-key
=
${appinsights_key}
azure.application-insights.instrumentation-key
=
${appinsights_key}
spring.application.name
=
workflow-azure
# Airflow configuration
# Airflow configuration
osdu.azure.airflow.url
=
${airflow_url}
osdu.azure.airflow.url
=
${airflow_url}
...
...
provider/workflow-azure/src/test/java/org/opengroup/osdu/workflow/provider/azure/fileshare/FileShare
ClientFactory
Test.java
→
provider/workflow-azure/src/test/java/org/opengroup/osdu/workflow/provider/azure/fileshare/FileShare
StoreProvider
Test.java
View file @
88cd2161
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
import
com.azure.storage.file.share.ShareClient
;
import
com.azure.storage.file.share.ShareClient
;
import
com.azure.storage.file.share.ShareDirectoryClient
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.Mock
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
/**
* Tests for {@link FileShare
ClientFactory
}
* Tests for {@link FileShare
StoreProvider
}
*/
*/
@ExtendWith
(
MockitoExtension
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
public
class
FileShareClientFactoryTest
{
public
class
FileShareStoreProviderTest
{
private
static
final
String
DAGS_FOLDER
=
"dagsTest"
;
@Mock
@Mock
private
ShareClient
shareClient
;
private
ShareClient
shareClient
;
@Mock
private
FileShareConfig
config
;
@Mock
private
ShareDirectoryClient
directoryClient
;
@InjectMocks
@InjectMocks
private
FileShare
ClientFactory
fileShareClientFactory
;
private
FileShare
StoreProvider
fileShareStoreProvider
;
@Test
@Test
public
void
testGetClient
()
{
public
void
testBuildDagsStore
()
{
assertThat
(
fileShareClientFactory
.
getClient
(),
equalTo
(
shareClient
));
when
(
config
.
getDagsFolder
()).
thenReturn
(
DAGS_FOLDER
);
}
when
(
shareClient
.
getDirectoryClient
(
eq
(
DAGS_FOLDER
))).
thenReturn
(
directoryClient
);
fileShareStoreProvider
.
buildDagsStore
(
shareClient
,
config
);
verify
(
config
).
getDagsFolder
();
verify
(
shareClient
).
getDirectoryClient
(
eq
(
DAGS_FOLDER
));
}
}
}
provider/workflow-azure/src/test/java/org/opengroup/osdu/workflow/provider/azure/fileshare/FileShareStoreTest.java
View file @
88cd2161
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
package
org.opengroup.osdu.workflow.provider.azure.fileshare
;
import
com.azure.storage.file.share.ShareClient
;
import
com.azure.storage.file.share.ShareClient
;
import
com.azure.storage.file.share.ShareDirectoryClient
;
import
com.azure.storage.file.share.ShareFileClient
;
import
com.azure.storage.file.share.ShareFileClient
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
...
@@ -30,10 +31,7 @@ public class FileShareStoreTest {
...
@@ -30,10 +31,7 @@ public class FileShareStoreTest {
private
static
final
long
CONTENT_LENGTH
=
CONTENTS
.
getBytes
().
length
;
private
static
final
long
CONTENT_LENGTH
=
CONTENTS
.
getBytes
().
length
;
@Mock
@Mock
private
IFileShareClientFactory
fileShareClientFactory
;
private
ShareDirectoryClient
shareDirectoryClient
;
@Mock
private
ShareClient
shareClient
;
@Mock
@Mock
private
ShareFileClient
shareFileClient
;
private
ShareFileClient
shareFileClient
;
...
@@ -41,19 +39,13 @@ public class FileShareStoreTest {
...
@@ -41,19 +39,13 @@ public class FileShareStoreTest {
@InjectMocks
@InjectMocks
private
FileShareStore
fileShareStore
;
private
FileShareStore
fileShareStore
;
@BeforeEach
public
void
setup
()
{
when
(
fileShareClientFactory
.
getClient
()).
thenReturn
(
shareClient
);
}
@Test
@Test
public
void
testCreateFile
()
{
public
void
testCreateFile
()
{
when
(
shareClient
.
createFile
(
eq
(
NAME
),
eq
(
CONTENT_LENGTH
))).
thenReturn
(
shareFileClient
);
when
(
share
Directory
Client
.
createFile
(
eq
(
NAME
),
eq
(
CONTENT_LENGTH
))).
thenReturn
(
shareFileClient
);
final
ArgumentCaptor
<
InputStream
>
inputStreamArgumentCaptor
=
ArgumentCaptor
.
forClass
(
InputStream
.
class
);
final
ArgumentCaptor
<
InputStream
>
inputStreamArgumentCaptor
=
ArgumentCaptor
.
forClass
(
InputStream
.
class
);
when
(
shareFileClient
.
upload
(
inputStreamArgumentCaptor
.
capture
(),
eq
(
CONTENT_LENGTH
))).
thenReturn
(
null
);
when
(
shareFileClient
.
upload
(
inputStreamArgumentCaptor
.
capture
(),
eq
(
CONTENT_LENGTH
))).
thenReturn
(
null
);
fileShareStore
.
createFile
(
CONTENTS
,
NAME
);
fileShareStore
.
createFile
(
CONTENTS
,
NAME
);
verify
(
fileShareClientFactory
,
times
(
1
)).
getClient
();
verify
(
shareDirectoryClient
,
times
(
1
)).
createFile
(
eq
(
NAME
),
eq
(
CONTENT_LENGTH
));
verify
(
shareClient
,
times
(
1
)).
createFile
(
eq
(
NAME
),
eq
(
CONTENT_LENGTH
));
verify
(
shareFileClient
,
times
(
1
)).
upload
(
any
(
InputStream
.
class
),
eq
(
CONTENT_LENGTH
));
verify
(
shareFileClient
,
times
(
1
)).
upload
(
any
(
InputStream
.
class
),
eq
(
CONTENT_LENGTH
));
}
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment