Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
5cf94214
Commit
5cf94214
authored
4 years ago
by
Lorenz Boguhn
Browse files
Options
Downloads
Patches
Plain Diff
added a crd test
parent
29c2f7c4
No related branches found
No related tags found
4 merge requests
!159
Re-implementation of Theodolite with Kotlin/Quarkus
,
!157
Update Graal Image in CI pipeline
,
!101
Add Service Monitor
,
!83
WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theodolite-quarkus/src/test/kotlin/theodolite/CustomRessourceTest.kt
+84
-0
84 additions, 0 deletions
...quarkus/src/test/kotlin/theodolite/CustomRessourceTest.kt
with
84 additions
and
0 deletions
theodolite-quarkus/src/test/kotlin/theodolite/CustomRessourceTest.kt
0 → 100644
+
84
−
0
View file @
5cf94214
package
theodolite
import
io.fabric8.kubernetes.client.DefaultKubernetesClient
import
io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
import
io.quarkus.test.junit.QuarkusTest
import
io.smallrye.common.constraint.Assert.assertTrue
import
org.junit.jupiter.api.Test
import
theodolite.k8s.K8sResourceLoader
import
io.fabric8.kubernetes.api.model.ObjectMeta
import
io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition
import
io.fabric8.kubernetes.client.CustomResource
import
io.fabric8.kubernetes.api.model.HasMetadata
import
io.fabric8.kubernetes.internal.KubernetesDeserializer
import
java.io.File
import
javax.json.Json
@QuarkusTest
class
CustomRessourceTest
{
val
client
=
DefaultKubernetesClient
()
val
loader
=
K8sResourceLoader
(
client
)
val
path
=
"./src/main/resources/yaml/"
@Test
fun
aids
(){
val
crd
=
loader
.
loadK8sResource
(
"ServiceMonitor"
,
path
+
"uc1-service-monitor.yaml"
)
val
crds
=
client
.
apiextensions
().
v1beta1
().
customResourceDefinitions
().
list
()
println
(
crd
.
toString
())
// val context = CustomResourceDefinitionContext.Builder().build()
//.withGroup()
//.withScope()
//.withPlural()
//.withKind("ServiceMonitor").build()
//.withName("kafka")
//
// println(client.customResource(context).list("default"))
//
// client.customResource(context).create(crd.toString())
val
crdsItems
=
crds
.
getItems
()
println
(
"Found ${crdsItems.size} CRD(s)"
)
var
dummy
:
CustomResourceDefinition
?
=
null
val
dummyCRDName
:
String
=
"servicemonitors.monitoring.coreos.com"
for
(
crd
in
crdsItems
)
{
val
metadata
:
ObjectMeta
=
crd
.
getMetadata
()
if
(
metadata
!=
null
)
{
val
name
=
metadata
.
name
//println(" " + name + " => " + metadata.selfLink)
if
(
dummyCRDName
.
equals
(
name
))
{
dummy
=
crd
;
println
(
"dummy found"
)
}
}
}
val
context
=
CustomResourceDefinitionContext
.
fromCrd
(
dummy
)
val
customclient
=
client
.
customResource
(
context
)
println
(
customclient
.
list
())
val
f
=
File
(
path
+
"uc1-service-monitor.yaml"
)
val
customr
=
customclient
.
load
(
f
.
inputStream
())
println
(
"Customressource: $customr"
)
println
(
"Dummy: $dummy"
)
customclient
.
create
(
customr
)
}
//@Test
fun
loadTest
(){
val
crd
=
loader
.
loadK8sResource
(
"ServiceMonitor"
,
path
+
"uc1-service-monitor.yaml"
)
println
(
crd
)
}
}
\ No newline at end of file
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