-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bipul Adhikari <[email protected]>
- Loading branch information
Showing
5 changed files
with
222 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
export const compressionPool = { | ||
apiVersion: 'ceph.rook.io/v1', | ||
kind: 'CephBlockPool', | ||
metadata: { name: 'plasma-reactor-pool', namespace: 'openshift-storage' }, | ||
spec: { | ||
compressionMode: 'aggressive', | ||
deviceClass: 'ssd', | ||
failureDomain: 'zone', | ||
parameters: { compression_mode: 'aggressive' }, | ||
replicated: { size: 2 }, | ||
}, | ||
}; | ||
|
||
export const compressionStorageClass = { | ||
kind: 'StorageClass', | ||
apiVersion: 'storage.k8s.io/v1', | ||
metadata: { | ||
name: 'compression-class', | ||
}, | ||
provisioner: 'openshift-storage.rbd.csi.ceph.com', | ||
parameters: { | ||
'csi.storage.k8s.io/fstype': 'ext4', | ||
'csi.storage.k8s.io/provisioner-secret-namespace': 'openshift-storage', | ||
'csi.storage.k8s.io/provisioner-secret-name': 'rook-csi-rbd-provisioner', | ||
'csi.storage.k8s.io/node-stage-secret-name': 'rook-csi-rbd-node', | ||
'csi.storage.k8s.io/controller-expand-secret-name': | ||
'rook-csi-rbd-provisioner', | ||
imageFormat: '2', | ||
clusterID: 'openshift-storage', | ||
imageFeatures: 'layering,deep-flatten,exclusive-lock,object-map,fast-diff', | ||
'csi.storage.k8s.io/controller-expand-secret-namespace': | ||
'openshift-storage', | ||
pool: 'plasma-reactor-pool', | ||
'csi.storage.k8s.io/node-stage-secret-namespace': 'openshift-storage', | ||
}, | ||
reclaimPolicy: 'Delete', | ||
allowVolumeExpansion: true, | ||
volumeBindingMode: 'Immediate', | ||
}; | ||
|
||
export const fioPVC = { | ||
kind: 'PersistentVolumeClaim', | ||
apiVersion: 'v1', | ||
metadata: { | ||
name: 'fio-claim', | ||
}, | ||
spec: { | ||
storageClassName: 'compression-class', | ||
accessModes: ['ReadWriteOnce'], | ||
volumeMode: 'Filesystem', | ||
resources: { | ||
requests: { | ||
storage: '5Gi', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const fioConfig = `kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: fio-job-config | ||
data: | ||
fio.job: |- | ||
[global] | ||
ioengine=psync | ||
direct=1 | ||
buffered=0 | ||
size=1G | ||
iodepth=1000 | ||
numjobs=2 | ||
group_reporting | ||
refill_buffers | ||
rwmixread=80 | ||
norandommap | ||
randrepeat=0 | ||
percentage_random=0 | ||
bs=512K | ||
buffer_compress_percentage=50 | ||
rw=read | ||
[testjob] | ||
`; | ||
|
||
export const fioJob = { | ||
apiVersion: 'batch/v1', | ||
kind: 'Job', | ||
metadata: { | ||
name: 'fio', | ||
labels: { | ||
app: 'fio', | ||
}, | ||
}, | ||
spec: { | ||
template: { | ||
spec: { | ||
containers: [ | ||
{ | ||
name: 'fio', | ||
image: 'quay.io/badhikar/fio:latest', | ||
command: ['sh'], | ||
args: [ | ||
'-c', | ||
// eslint-disable-next-line no-template-curly-in-string | ||
'echo ${HOSTNAME} && mkdir -p /scratch/${HOSTNAME} && fio /configs/fio.job --eta=never --directory=/scratch/${HOSTNAME}', | ||
], | ||
volumeMounts: [ | ||
{ | ||
name: 'fio-config-vol', | ||
mountPath: '/configs', | ||
}, | ||
{ | ||
name: 'fio-data', | ||
mountPath: '/scratch', | ||
}, | ||
], | ||
imagePullPolicy: 'Always', | ||
}, | ||
], | ||
restartPolicy: 'OnFailure', | ||
volumes: [ | ||
{ | ||
name: 'fio-config-vol', | ||
configMap: { | ||
name: 'fio-job-config', | ||
}, | ||
}, | ||
{ | ||
name: 'fio-data', | ||
persistentVolumeClaim: { | ||
claimName: 'fio-claim', | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
compressionPool, | ||
compressionStorageClass, | ||
fioConfig, | ||
fioJob, | ||
fioPVC, | ||
} from '../mocks/compression'; | ||
import { navigateToBlockPool } from '../views/block-pool'; | ||
import { commandPoll } from '../views/common'; | ||
|
||
describe('Test Pool Compression', () => { | ||
before(() => { | ||
cy.login(); | ||
cy.visit('/'); | ||
cy.install(); | ||
cy.enableToolboxPod(); | ||
cy.exec(`echo '${JSON.stringify(compressionPool)}' | oc apply -f -`); | ||
cy.exec( | ||
`echo '${JSON.stringify(compressionStorageClass)}' | oc apply -f -` | ||
); | ||
cy.exec(`echo '${fioConfig}' | oc apply -f -`); | ||
cy.exec(`echo '${JSON.stringify(fioPVC)}' | oc apply -f -`); | ||
cy.exec(`echo '${JSON.stringify(fioJob)}' | oc apply -f -`); | ||
commandPoll('oc get job fio', null, false, 30, 0); | ||
cy.exec(`oc wait --for=condition=complete job fio`, { timeout: 120000 }); | ||
}); | ||
|
||
after(() => { | ||
cy.exec(`echo ${JSON.stringify(fioJob)} | oc delete -f -`); | ||
cy.exec(`echo ${JSON.stringify(fioPVC)} | oc delete -f -`); | ||
cy.exec(`echo ${JSON.stringify(fioConfig)} | oc delete -f -`); | ||
cy.exec(`echo ${JSON.stringify(compressionPool)} | oc delete -f -`); | ||
cy.exec(`echo ${JSON.stringify(compressionStorageClass)} | oc delete -f -`); | ||
cy.logout(); | ||
}); | ||
|
||
it('Tests compression statistics are correct on the BlockPool list Page', () => { | ||
navigateToBlockPool(); | ||
cy.byTestID('name-filter-input').type(compressionPool.metadata.name); | ||
// TableData does not support data-test ids | ||
// eslint-disable-next-line cypress/require-data-selectors | ||
cy.get('#compressionStatus').should('have.text', 'Enabled'); | ||
cy.exec( | ||
`oc exec -it $(oc get pods -n openshift-storage -l app=rook-ceph-tools -o name) -n openshift-storage -- /usr/bin/rados df -f json` | ||
).then(({ stdout }) => { | ||
const poolData = JSON.parse(stdout).pools; | ||
const plasmaPool = poolData.find( | ||
(pool) => pool.name === compressionPool.metadata.name | ||
); | ||
const compressionSavings = plasmaPool.compress_bytes_used; | ||
// TableData does not support data-test ids | ||
// eslint-disable-next-line cypress/require-data-selectors | ||
cy.get('#compressionSavings').should( | ||
'have.text', | ||
(compressionSavings / 1024 ** 2).toFixed(2) | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters