Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
org.etsi.osl.cridge
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSL
code
org.etsi.osl.cridge
Commits
e4be9af4
Commit
e4be9af4
authored
1 year ago
by
tranoris
Browse files
Options
Downloads
Patches
Plain Diff
changing activate profile
parent
ad1015fc
No related branches found
No related tags found
1 merge request
!8
Merging 2024Q2_RC into main, creating 2024Q2 Release
Pipeline
#5710
passed
1 year ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pom.xml
+2
-2
2 additions, 2 deletions
pom.xml
src/main/resources/application.yml
+0
-3
0 additions, 3 deletions
src/main/resources/application.yml
src/test/java/org/etsi/osl/cridge/CridgeIntegrationTest.java
+172
-172
172 additions, 172 deletions
src/test/java/org/etsi/osl/cridge/CridgeIntegrationTest.java
with
174 additions
and
177 deletions
pom.xml
+
2
−
2
View file @
e4be9af4
...
...
@@ -19,15 +19,15 @@
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<!--
<spring.boot-version>
3.2.2
</spring.boot-version>
<spring.boot.fabric8-version>
3.1.0
</spring.boot.fabric8-version>
<fabric8.version>
6.10.0
</fabric8.version>
-->
<!--
<spring.boot-version>${spring-boot-version}</spring.boot-version>
<spring.boot.fabric8-version>3.0.5</spring.boot.fabric8-version>
<fabric8.version>6.6.2</fabric8.version>
-->
<camel.version>
4.0.0-RC1
</camel.version>
<slf4j-api.version>
1.7.5
</slf4j-api.version>
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/application.yml
+
0
−
3
View file @
e4be9af4
spring
:
config
:
activate
:
on-profile
:
"
default"
application
:
name
:
cridge
main
:
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/etsi/osl/cridge/CridgeIntegrationTest.java
+
172
−
172
View file @
e4be9af4
...
...
@@ -176,139 +176,139 @@ public class CridgeIntegrationTest {
}
// @Test
// public void testCRDEPLOY() throws Exception {
// logger.info("===============TEST testCRDEPLOY =============================");
//
//
// // CustomResourceDefinition cronTabCrd = routesPreparation.kubernetesClient.apiextensions().v1()
// // .customResourceDefinitions()
// // .load(new BufferedInputStream(new FileInputStream("src/test/resources/crontab-crd.yaml")))
// // .item();
//
//
// // prepare CR_SPEC request
// CustomResourceDefinition crdMyCalc = v1CRDFromCustomResourceType(MyCalculator.class).build();
//
//
//
// Map<String, Object> map = new HashMap<>();
// map.put("currentContextCluster", "testCluster");
// map.put("clusterMasterURL", server.getHostName());
// map.put("org.etsi.osl.serviceId", "sid-xxx-xxx-xxx");
// map.put("org.etsi.osl.resourceId", "rid-xxx-xxx-xxx");
// map.put("org.etsi.osl.prefixName", "crrid12345");
// map.put("org.etsi.osl.serviceOrderId", "orderid-xxx-xxx-xxx");
// map.put("org.etsi.osl.namespace", "orderid-xxx-xxx-xxx");
// map.put("org.etsi.osl.statusCheckFieldName", "_CR_CHECK_FIELD");
// map.put("org.etsi.osl.statusCheckValueStandby", "_CR_CHECKVAL_STANDBY");
// map.put("org.etsi.osl.statusCheckValueAlarm", "_CR_CHECKVAL_ALARM");
// map.put("org.etsi.osl.statusCheckValueAvailable", "_CR_CHECKVAL_AVAILABLE");
// map.put("org.etsi.osl.statusCheckValueReserved", "_CR_CHECKVAL_RESERVED");
// map.put("org.etsi.osl.statusCheckValueUnknown", "_CR_CHECKVAL_UNKNOWN");
// map.put("org.etsi.osl.statusCheckValueSuspended", "_CR_CHECKVAL_SUSPENDED");
//
//
// String _CR_SPEC = Serialization.asYaml(getMyCalculator("test-resource"));
//
// // First check for an invalid context cluster
// String response = kubernetesClientResource.deployCR(map, _CR_SPEC);
// assertEquals("SEE OTHER", response);
//
//
// // Now try for the correct context cluster
// map.put("currentContextCluster",
// kubernetesClientResource.getKubernetesContextDefinition().getCurrentContextCluster());
// map.put("clusterMasterURL",
// kubernetesClientResource.getKubernetesContextDefinition().getMasterURL());
//
//
// // server api expectations
// server.expect().get()
// .withPath("/api/v1/namespaces/orderid-xxx-xxx-xxx/secrets?resourceVersion=0")
// .andReturn(HttpURLConnection.HTTP_OK, crdMyCalc).once();
//
// server.expect().get().withPath(
// "/api/v1/namespaces/orderid-xxx-xxx-xxx/secrets?allowWatchBookmarks=true&timeoutSeconds=600&watch=true")
// .andReturn(HttpURLConnection.HTTP_OK, crdMyCalc).once();
//
// server.expect().get()
// .withPath("/apis/stable.example.com/v1/namespaces/orderid-xxx-xxx-xxx/mycalculators")
// .andReturn(HttpURLConnection.HTTP_OK, crdMyCalc).once();
//
// server.expect().get().withPath(
// "/apis/stable.example.com/v1/namespaces/orderid-xxx-xxx-xxx/mycalculators/amycalculator")
// .andReturn(HttpURLConnection.HTTP_OK, crdMyCalc).once();
//
// server.expect().post().withPath("/api/v1/namespaces/orderid-xxx-xxx-xxx/mycalculators")
// .andReturn(HttpURLConnection.HTTP_CREATED, crdMyCalc).once();
//
// server.expect().post()
// .withPath(
// "/apis/examples.osl.etsi.org/v1alpha1/namespaces/orderid-xxx-xxx-xxx/mycalculators")
// .andReturn(HttpURLConnection.HTTP_CREATED, crdMyCalc).once();
//
// // register the resource handler
// KubernetesClient client = routesPreparation.kubernetesClient;
//
// client.getKubernetesSerialization().registerKubernetesResource("examples.osl.etsi.org/v1alpha1",
// "MyCalculator", MyCalculator.class);
//
// // make the deployment test!
// response = kubernetesClientResource.deployCR(map, _CR_SPEC);
//
// assertEquals("OK", response);
//
// }
@Test
public
void
testCRDEPLOY
()
throws
Exception
{
logger
.
info
(
"===============TEST testCRDEPLOY ============================="
);
// CustomResourceDefinition cronTabCrd = routesPreparation.kubernetesClient.apiextensions().v1()
// .customResourceDefinitions()
// .load(new BufferedInputStream(new FileInputStream("src/test/resources/crontab-crd.yaml")))
// .item();
// prepare CR_SPEC request
CustomResourceDefinition
crdMyCalc
=
v1CRDFromCustomResourceType
(
MyCalculator
.
class
).
build
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"currentContextCluster"
,
"testCluster"
);
map
.
put
(
"clusterMasterURL"
,
server
.
getHostName
());
map
.
put
(
"org.etsi.osl.serviceId"
,
"sid-xxx-xxx-xxx"
);
map
.
put
(
"org.etsi.osl.resourceId"
,
"rid-xxx-xxx-xxx"
);
map
.
put
(
"org.etsi.osl.prefixName"
,
"crrid12345"
);
map
.
put
(
"org.etsi.osl.serviceOrderId"
,
"orderid-xxx-xxx-xxx"
);
map
.
put
(
"org.etsi.osl.namespace"
,
"orderid-xxx-xxx-xxx"
);
map
.
put
(
"org.etsi.osl.statusCheckFieldName"
,
"_CR_CHECK_FIELD"
);
map
.
put
(
"org.etsi.osl.statusCheckValueStandby"
,
"_CR_CHECKVAL_STANDBY"
);
map
.
put
(
"org.etsi.osl.statusCheckValueAlarm"
,
"_CR_CHECKVAL_ALARM"
);
map
.
put
(
"org.etsi.osl.statusCheckValueAvailable"
,
"_CR_CHECKVAL_AVAILABLE"
);
map
.
put
(
"org.etsi.osl.statusCheckValueReserved"
,
"_CR_CHECKVAL_RESERVED"
);
map
.
put
(
"org.etsi.osl.statusCheckValueUnknown"
,
"_CR_CHECKVAL_UNKNOWN"
);
map
.
put
(
"org.etsi.osl.statusCheckValueSuspended"
,
"_CR_CHECKVAL_SUSPENDED"
);
String
_CR_SPEC
=
Serialization
.
asYaml
(
getMyCalculator
(
"test-resource"
));
// First check for an invalid context cluster
String
response
=
kubernetesClientResource
.
deployCR
(
map
,
_CR_SPEC
);
assertEquals
(
"SEE OTHER"
,
response
);
// Now try for the correct context cluster
map
.
put
(
"currentContextCluster"
,
kubernetesClientResource
.
getKubernetesContextDefinition
().
getCurrentContextCluster
());
map
.
put
(
"clusterMasterURL"
,
kubernetesClientResource
.
getKubernetesContextDefinition
().
getMasterURL
());
// server api expectations
server
.
expect
().
get
()
.
withPath
(
"/api/v1/namespaces/orderid-xxx-xxx-xxx/secrets?resourceVersion=0"
)
.
andReturn
(
HttpURLConnection
.
HTTP_OK
,
crdMyCalc
).
once
();
server
.
expect
().
get
().
withPath
(
"/api/v1/namespaces/orderid-xxx-xxx-xxx/secrets?allowWatchBookmarks=true&timeoutSeconds=600&watch=true"
)
.
andReturn
(
HttpURLConnection
.
HTTP_OK
,
crdMyCalc
).
once
();
server
.
expect
().
get
()
.
withPath
(
"/apis/stable.example.com/v1/namespaces/orderid-xxx-xxx-xxx/mycalculators"
)
.
andReturn
(
HttpURLConnection
.
HTTP_OK
,
crdMyCalc
).
once
();
server
.
expect
().
get
().
withPath
(
"/apis/stable.example.com/v1/namespaces/orderid-xxx-xxx-xxx/mycalculators/amycalculator"
)
.
andReturn
(
HttpURLConnection
.
HTTP_OK
,
crdMyCalc
).
once
();
server
.
expect
().
post
().
withPath
(
"/api/v1/namespaces/orderid-xxx-xxx-xxx/mycalculators"
)
.
andReturn
(
HttpURLConnection
.
HTTP_CREATED
,
crdMyCalc
).
once
();
server
.
expect
().
post
()
.
withPath
(
"/apis/examples.osl.etsi.org/v1alpha1/namespaces/orderid-xxx-xxx-xxx/mycalculators"
)
.
andReturn
(
HttpURLConnection
.
HTTP_CREATED
,
crdMyCalc
).
once
();
// register the resource handler
KubernetesClient
client
=
routesPreparation
.
kubernetesClient
;
client
.
getKubernetesSerialization
().
registerKubernetesResource
(
"examples.osl.etsi.org/v1alpha1"
,
"MyCalculator"
,
MyCalculator
.
class
);
// make the deployment test!
response
=
kubernetesClientResource
.
deployCR
(
map
,
_CR_SPEC
);
assertEquals
(
"OK"
,
response
);
}
@Test
public
void
testCRWithWatch
()
throws
Exception
{
// useful blog
// https://itnext.io/mock-kubernetes-api-server-in-java-using-fabric8-kubernetes-mock-server-81a75cf6c47c
// Given
KubernetesClient
client
=
routesPreparation
.
kubernetesClient
;
server
.
expect
().
withPath
(
"/apis/examples.osl.etsi.org/v1alpha1/namespaces/orderid-xxx-xxx-xxx/mycalculators?allowWatchBookmarks=true&watch=true"
)
.
andUpgradeToWebSocket
().
open
().
waitFor
(
10L
)
.
andEmit
(
new
WatchEvent
(
getMyCalculator
(
"amycalculator"
),
"ADDED"
)).
waitFor
(
20L
)
.
andEmit
(
new
WatchEventBuilder
().
withNewStatusObject
()
.
withMessage
(
"410 - the event requested is outdated"
)
.
withCode
(
HttpURLConnection
.
HTTP_GONE
).
endStatusObject
().
build
())
.
done
().
always
();
MixedOperation
<
MyCalculator
,
KubernetesResourceList
<
MyCalculator
>,
Resource
<
MyCalculator
>>
userAclClient
=
client
.
resources
(
MyCalculator
.
class
);
// @Test
// public void testCRWithWatch() throws Exception {
// // useful blog
// // https://itnext.io/mock-kubernetes-api-server-in-java-using-fabric8-kubernetes-mock-server-81a75cf6c47c
//
// // Given
// KubernetesClient client = routesPreparation.kubernetesClient;
//
// server.expect().withPath(
// "/apis/examples.osl.etsi.org/v1alpha1/namespaces/orderid-xxx-xxx-xxx/mycalculators?allowWatchBookmarks=true&watch=true")
// .andUpgradeToWebSocket().open().waitFor(10L)
// .andEmit(new WatchEvent(getMyCalculator("amycalculator"), "ADDED")).waitFor(20L)
// .andEmit(new WatchEventBuilder().withNewStatusObject()
// .withMessage("410 - the event requested is outdated")
// .withCode(HttpURLConnection.HTTP_GONE).endStatusObject().build())
// .done().always();
//
// MixedOperation<MyCalculator, KubernetesResourceList<MyCalculator>, Resource<MyCalculator>> userAclClient =
// client.resources(MyCalculator.class);
//
//
// // When
// CountDownLatch eventRecieved = new CountDownLatch(1);
// client.getKubernetesSerialization().registerKubernetesResource("examples.osl.etsi.org/v1alpha1",
// "MyCalculator", MyCalculator.class);
//
// Watch watch =
// userAclClient.inNamespace("orderid-xxx-xxx-xxx").watch(new Watcher<MyCalculator>() {
// @Override
// public void eventReceived(Action action, MyCalculator calc) {
// if (action.name().contains("ADDED")) {
// eventRecieved.countDown();
// logger.info(
// "===============CountDownLatch eventRecieved.countDown ADDED {}=============================",
// Serialization.asYaml(calc));
// }
// }
//
// @Override
// public void onClose(WatcherException e) {}
// });
//
// // Then
// eventRecieved.await(30, TimeUnit.SECONDS);
// Assertions.assertEquals(0, eventRecieved.getCount());
// watch.close();
//
// }
// When
CountDownLatch
eventRecieved
=
new
CountDownLatch
(
1
);
client
.
getKubernetesSerialization
().
registerKubernetesResource
(
"examples.osl.etsi.org/v1alpha1"
,
"MyCalculator"
,
MyCalculator
.
class
);
Watch
watch
=
userAclClient
.
inNamespace
(
"orderid-xxx-xxx-xxx"
).
watch
(
new
Watcher
<
MyCalculator
>()
{
@Override
public
void
eventReceived
(
Action
action
,
MyCalculator
calc
)
{
if
(
action
.
name
().
contains
(
"ADDED"
))
{
eventRecieved
.
countDown
();
logger
.
info
(
"===============CountDownLatch eventRecieved.countDown ADDED {}============================="
,
Serialization
.
asYaml
(
calc
));
}
}
@Override
public
void
onClose
(
WatcherException
e
)
{}
});
// Then
eventRecieved
.
await
(
30
,
TimeUnit
.
SECONDS
);
Assertions
.
assertEquals
(
0
,
eventRecieved
.
getCount
());
watch
.
close
();
}
private
KubernetesResource
getMyCalculator
(
String
resourceName
)
{
...
...
@@ -332,47 +332,47 @@ public class CridgeIntegrationTest {
}
// @Test
// public void testKubernetesCRD2OpensliceCRD() throws FileNotFoundException {
//
// logger.info("===============TEST testCRDRegister =============================");
// // CustomResourceDefinition crdMyCalc = v1CRDFromCustomResourceType(MyCalculator.class).build();
// CustomResourceDefinition cronTabCrd =
// routesPreparation.kubernetesClient.apiextensions().v1().customResourceDefinitions()
// .load(
// new BufferedInputStream(new FileInputStream("src/test/resources/crontab-crd.yaml")))
// .item();
//
// List<KubernetesCRDV1> value = kubernetesClientResource.KubernetesCRD2OpensliceCRD(cronTabCrd);
//
// assertEquals(1, value.size());
// assertEquals("CronTab", value.get(0).getKind());
// assertEquals("v1", value.get(0).getVersion());
// assertEquals("stable.example.com", value.get(0).getApiGroup());
//
//
// }
@Test
public
void
testKubernetesCRD2OpensliceCRD
()
throws
FileNotFoundException
{
// @Test
// public void testKubernetesCRDOpensliceCR() throws FileNotFoundException {
//
//
// logger.info("===============TEST testCRRegister =============================");
//
// ResourceDefinitionContext resourceDefinitionContext = new ResourceDefinitionContext.Builder()
// .withGroup("stable.example.com").withVersion("v1").withPlural("crontabs").build();
//
// GenericKubernetesResource cronTabCr =
// routesPreparation.kubernetesClient.genericKubernetesResources(resourceDefinitionContext)
// .load(new FileInputStream("src/test/resources/crontab-cr.yaml")).item();
//
//
// KubernetesCRV1 value = kubernetesClientResource.KubernetesCR2OpensliceCR(cronTabCr);
//
// assertEquals("CronTab", value.getKind());
//
//
// }
logger
.
info
(
"===============TEST testCRDRegister ============================="
);
// CustomResourceDefinition crdMyCalc = v1CRDFromCustomResourceType(MyCalculator.class).build();
CustomResourceDefinition
cronTabCrd
=
routesPreparation
.
kubernetesClient
.
apiextensions
().
v1
().
customResourceDefinitions
()
.
load
(
new
BufferedInputStream
(
new
FileInputStream
(
"src/test/resources/crontab-crd.yaml"
)))
.
item
();
List
<
KubernetesCRDV1
>
value
=
kubernetesClientResource
.
KubernetesCRD2OpensliceCRD
(
cronTabCrd
);
assertEquals
(
1
,
value
.
size
());
assertEquals
(
"CronTab"
,
value
.
get
(
0
).
getKind
());
assertEquals
(
"v1"
,
value
.
get
(
0
).
getVersion
());
assertEquals
(
"stable.example.com"
,
value
.
get
(
0
).
getApiGroup
());
}
@Test
public
void
testKubernetesCRDOpensliceCR
()
throws
FileNotFoundException
{
logger
.
info
(
"===============TEST testCRRegister ============================="
);
ResourceDefinitionContext
resourceDefinitionContext
=
new
ResourceDefinitionContext
.
Builder
()
.
withGroup
(
"stable.example.com"
).
withVersion
(
"v1"
).
withPlural
(
"crontabs"
).
build
();
GenericKubernetesResource
cronTabCr
=
routesPreparation
.
kubernetesClient
.
genericKubernetesResources
(
resourceDefinitionContext
)
.
load
(
new
FileInputStream
(
"src/test/resources/crontab-cr.yaml"
)).
item
();
KubernetesCRV1
value
=
kubernetesClientResource
.
KubernetesCR2OpensliceCR
(
cronTabCr
);
assertEquals
(
"CronTab"
,
value
.
getKind
());
}
@Test
public
void
testKubernetesSecret2OpensliceResource
()
throws
FileNotFoundException
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment