Skip to content

Commit

Permalink
Merge pull request #1455 from NASA-AMMOS/feature/e2e_sequencing_chann…
Browse files Browse the repository at this point in the history
…el_parameter_support

Sequencing e2e - Added channel/parameter and DB state test
  • Loading branch information
goetzrrGit authored Aug 6, 2024
2 parents a505cf9 + ccd4e4f commit 1ce729a
Show file tree
Hide file tree
Showing 15 changed files with 831 additions and 130 deletions.
35 changes: 35 additions & 0 deletions sequencing-server/cdict/channel_banananation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<telemetry_dictionary>
<header mission_name="Banana Nation" version="1.0.0.0" schema_version="1.0">
<spacecraft_ids>
<spacecraft_id value="62"/>
</spacecraft_ids>
</header>
<enum_definitions>
<enum_table name="BAKE_STATE">
<values>
<enum symbol="OVEN_OFF" numeric="0"/>
<enum symbol="OVEN_ON" numeric="0"/>
</values>
</enum_table>
</enum_definitions>
<telemetry_groups>
<group group_name="oven_model" group_desc="different oven models">
<group_channel>OVEN-21</group_channel>
<group_channel>OVEN-26</group_channel>
</group>
</telemetry_groups>
<telemetry_definitions>
<telemetry abbreviation="BAKE-0000" channel_derivation="None" name="BAKE_STATE" type="enum" source="flight" byte_length="1">
<measurement_id>1</measurement_id>
<description>String of the oven</description>
<enum_format enum_name="BAKE_STATE"/>
<raw_units>None</raw_units>
<categories>
<module>oven_sc</module>
<ops_category>BAKE</ops_category>
</categories>
<fsw_specification oven_buffer_depth="4"/>
</telemetry>
</telemetry_definitions>
</telemetry_dictionary>
34 changes: 34 additions & 0 deletions sequencing-server/cdict/parameter_banananation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<param-def>
<header mission_name="Banana Nation" version="1.0.0.1" schema_version="1.0">
<spacecraft_ids>
<spacecraft_id value="62"/>
</spacecraft_ids>
</header>
<enum_definitions>
<enum_table name="BANANA">
<values>
<enum symbol="BANANA_YELLOW" numeric="0"/>
<enum symbol="BANANA_GREEN" numeric="1"/>
</values>
</enum_table>
</enum_definitions>
<param param_id="0x6260" param_name="BANANA_COLOR_RATE" parameter_version="1" units="shade/second" location="TREE" managed_by="Ground">
<sysdesc>The rate that the banana changes form green to yellow</sysdesc>
<when_applied applied="IMMEDIATELY"/>
<categories>
<module>banana_mgr</module>
<ops_category>BANANA</ops_category>
</categories>
<parameter_type>
<unsigned_int_param bit_length="8">
<range_of_values>
<include min="1" max="4"/>
</range_of_values>
</unsigned_int_param>
</parameter_type>
<param_validation custom_validation_required="No"/>
<default_value>1</default_value>
<rationale>This is the rate that the banana can change color for all bananas</rationale>
</param>
</param-def>
23 changes: 19 additions & 4 deletions sequencing-server/test/batchLoaders/expansionBatchLoader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@ import type { GraphQLClient } from 'graphql-request';
import { insertExpansion, removeExpansion } from '../testUtils/Expansion';
import { expansionBatchLoader } from '../../src/lib/batchLoaders/expansionBatchLoader';
import { getGraphQLClient } from '../testUtils/testUtils';
import { insertCommandDictionary, removeCommandDictionary } from '../testUtils/CommandDictionary';
import { insertDictionary, removeDictionary } from '../testUtils/Dictionary';
import { insertParcel, removeParcel } from '../testUtils/Parcel';
import { DictionaryType } from '../../src/types/types';

let graphqlClient: GraphQLClient;
let expansionId: number;
let commandDictionaryId: number;
let channelDictionaryId: number;
let parameterDictionaryId: number;
let parcelId: number;

beforeAll(async () => {
graphqlClient = await getGraphQLClient();
commandDictionaryId = (await insertCommandDictionary(graphqlClient)).id;
parcelId = (await insertParcel(graphqlClient, commandDictionaryId, 'expansionBatchLoaderTestParcel')).parcelId;
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
parcelId = (
await insertParcel(
graphqlClient,
commandDictionaryId,
channelDictionaryId,
parameterDictionaryId,
'expansionBatchLoaderTestParcel',
)
).parcelId;

expansionId = await insertExpansion(
graphqlClient,
Expand All @@ -32,7 +45,9 @@ beforeAll(async () => {
afterAll(async () => {
await removeExpansion(graphqlClient, expansionId);
await removeParcel(graphqlClient, parcelId);
await removeCommandDictionary(graphqlClient, commandDictionaryId);
await removeDictionary(graphqlClient, commandDictionaryId, DictionaryType.COMMAND);
await removeDictionary(graphqlClient, channelDictionaryId, DictionaryType.CHANNEL);
await removeDictionary(graphqlClient, parameterDictionaryId, DictionaryType.PARAMETER);
});

it('should load expansion data', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,34 @@ import type { GraphQLClient } from 'graphql-request';
import { expansionSetBatchLoader } from '../../src/lib/batchLoaders/expansionSetBatchLoader.js';
import { removeMissionModel, uploadMissionModel } from '../testUtils/MissionModel.js';
import { insertExpansion, insertExpansionSet, removeExpansion, removeExpansionSet } from '../testUtils/Expansion';
import { insertCommandDictionary, removeCommandDictionary } from '../testUtils/CommandDictionary';
import { insertDictionary, removeDictionary } from '../testUtils/Dictionary';
import { getGraphQLClient } from '../testUtils/testUtils.js';
import { insertParcel, removeParcel } from '../testUtils/Parcel';
import { DictionaryType } from '../../src/types/types';

let graphqlClient: GraphQLClient;
let missionModelId: number;
let expansionId: number;
let expansionSetId: number;
let commandDictionaryId: number;
let channelDictionaryId: number;
let paramaterDictionaryId: number;
let parcelId: number;

beforeAll(async () => {
graphqlClient = await getGraphQLClient();
commandDictionaryId = (await insertCommandDictionary(graphqlClient)).id;
parcelId = (await insertParcel(graphqlClient, commandDictionaryId, 'expansionSetBatchLoaderTestParcel')).parcelId;
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
paramaterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
parcelId = (
await insertParcel(
graphqlClient,
commandDictionaryId,
channelDictionaryId,
paramaterDictionaryId,
'expansionSetBatchLoaderTestParcel',
)
).parcelId;
});

beforeAll(async () => {
Expand All @@ -38,7 +51,9 @@ afterAll(async () => {
await removeExpansionSet(graphqlClient, expansionSetId);
await removeExpansion(graphqlClient, expansionId);
await removeParcel(graphqlClient, parcelId);
await removeCommandDictionary(graphqlClient, commandDictionaryId);
await removeDictionary(graphqlClient, commandDictionaryId, DictionaryType.COMMAND);
await removeDictionary(graphqlClient, channelDictionaryId, DictionaryType.CHANNEL);
await removeDictionary(graphqlClient, paramaterDictionaryId, DictionaryType.PARAMETER);
await removeMissionModel(graphqlClient, missionModelId);
await removeMissionModel(graphqlClient, missionModelId);
});
Expand Down
29 changes: 0 additions & 29 deletions sequencing-server/test/command-dictionary.spec.ts

This file was deleted.

89 changes: 81 additions & 8 deletions sequencing-server/test/command-expansion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
insertActivityDirective,
removeActivityDirective,
} from './testUtils/ActivityDirective.js';
import { insertCommandDictionary, removeCommandDictionary } from './testUtils/CommandDictionary.js';
import { insertDictionary, removeDictionary } from './testUtils/Dictionary';
import {
expand,
getExpandedSequence,
Expand All @@ -22,17 +22,30 @@ import { executeSimulation, removeSimulationArtifacts, updateSimulationBounds }
import { getGraphQLClient, waitMs } from './testUtils/testUtils';
import { insertSequence, linkActivityInstance } from './testUtils/Sequence.js';
import { insertParcel, removeParcel } from './testUtils/Parcel';
import { DictionaryType } from '../src/types/types';

let planId: number;
let graphqlClient: GraphQLClient;
let missionModelId: number;
let commandDictionaryId: number;
let channelDictionaryId: number;
let parameterDictionaryId: number;
let parcelId: number;

beforeAll(async () => {
graphqlClient = await getGraphQLClient();
commandDictionaryId = (await insertCommandDictionary(graphqlClient)).id;
parcelId = (await insertParcel(graphqlClient, commandDictionaryId, 'expansionTestParcel')).parcelId;
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
parcelId = (
await insertParcel(
graphqlClient,
commandDictionaryId,
channelDictionaryId,
parameterDictionaryId,
'expansionTestParcel',
)
).parcelId;
});

beforeEach(async () => {
Expand All @@ -47,7 +60,9 @@ beforeEach(async () => {

afterAll(async () => {
await removeParcel(graphqlClient, parcelId);
await removeCommandDictionary(graphqlClient, commandDictionaryId);
await removeDictionary(graphqlClient, commandDictionaryId, DictionaryType.COMMAND);
await removeDictionary(graphqlClient, channelDictionaryId, DictionaryType.CHANNEL);
await removeDictionary(graphqlClient, parameterDictionaryId, DictionaryType.PARAMETER);
});

afterEach(async () => {
Expand Down Expand Up @@ -493,17 +508,75 @@ describe('expansion', () => {
expect(testProvidedExpansionSetId).toBeNumber();

const testProvidedResp = await getExpansionSet(graphqlClient, testProvidedExpansionSetId);
expect(testProvidedResp.expansion_set_by_pk.name).toBe(name);
expect(testProvidedResp.expansion_set_by_pk.description).toBe(description);
expect(testProvidedResp).not.toBeNull();
expect(testProvidedResp?.name).toBe(name);
expect(testProvidedResp?.description).toBe(description);

const testDefaultExpansionSetId = await insertExpansionSet(graphqlClient, parcelId, missionModelId, [expansionId]);
expect(testDefaultExpansionSetId).not.toBeNull();
expect(testDefaultExpansionSetId).toBeDefined();
expect(testDefaultExpansionSetId).toBeNumber();

const testDefaultResp = await getExpansionSet(graphqlClient, testDefaultExpansionSetId);
expect(testDefaultResp).not.toBeNull();
expect(testDefaultResp?.name).toBe('');
expect(testDefaultResp?.description).toBe('');

// Cleanup
await removeExpansion(graphqlClient, expansionId);
await removeExpansionSet(graphqlClient, testProvidedExpansionSetId);
await removeExpansionSet(graphqlClient, testProvidedExpansionSetId);
});

it('should handle optional channel and parameter dictionaries', async () => {
// Remove the optional dictionarys
await removeDictionary(graphqlClient, channelDictionaryId, DictionaryType.CHANNEL);
await removeDictionary(graphqlClient, parameterDictionaryId, DictionaryType.PARAMETER);

const expansionId = await insertExpansion(
graphqlClient,
'GrowBanana',
`
export default function SingleCommandExpansion(props: {
activityInstance: ActivityType,
channelDictionary: ChannelDictionary | null,
parameterDictionaries : ParameterDictionary[]
}): ExpansionReturn {
return [
A\`2023-091T10:00:00.000\`.ADD_WATER,
R\`04:00:00.000\`.GROW_BANANA({ quantity: 10, durationSecs: 7200 })
];
}
`,
parcelId,
);
const name = 'test name';
const description = 'test desc';

const testProvidedExpansionSetId = await insertExpansionSet(
graphqlClient,
parcelId,
missionModelId,
[expansionId],
description,
name,
);
expect(testProvidedExpansionSetId).not.toBeNull();
expect(testProvidedExpansionSetId).toBeDefined();
expect(testProvidedExpansionSetId).toBeNumber();

const testProvidedResp = await getExpansionSet(graphqlClient, testProvidedExpansionSetId);
expect(testProvidedResp?.name).toBe(name);
expect(testProvidedResp?.description).toBe(description);

const testDefaultExpansionSetId = await insertExpansionSet(graphqlClient, parcelId, missionModelId, [expansionId]);
expect(testDefaultExpansionSetId).not.toBeNull();
expect(testDefaultExpansionSetId).toBeDefined();
expect(testDefaultExpansionSetId).toBeNumber();

const testDefaultResp = await getExpansionSet(graphqlClient, testDefaultExpansionSetId);
expect(testDefaultResp.expansion_set_by_pk.name).toBe('');
expect(testDefaultResp.expansion_set_by_pk.description).toBe('');
expect(testDefaultResp?.name).toBe('');
expect(testDefaultResp?.description).toBe('');

// Cleanup
await removeExpansion(graphqlClient, expansionId);
Expand Down
13 changes: 10 additions & 3 deletions sequencing-server/test/command-types.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { gql, GraphQLClient } from 'graphql-request';
import { Status } from '../src/common.js';
import { insertCommandDictionary, removeCommandDictionary } from './testUtils/CommandDictionary.js';
import { insertDictionary, removeDictionary } from './testUtils/Dictionary';
import { getGraphQLClient } from './testUtils/testUtils.js';
import { DictionaryType } from '../src/types/types';

let graphqlClient: GraphQLClient;
let commandDictionaryId: number;
let channelDictionaryId: number;
let parameterDictionaryId: number;

beforeAll(async () => {
graphqlClient = await getGraphQLClient();
commandDictionaryId = (await insertCommandDictionary(graphqlClient)).id;
commandDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.COMMAND)).id;
channelDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.CHANNEL)).id;
parameterDictionaryId = (await insertDictionary(graphqlClient, DictionaryType.PARAMETER)).id;
});

afterAll(async () => {
removeCommandDictionary(graphqlClient, commandDictionaryId);
await removeDictionary(graphqlClient, commandDictionaryId, DictionaryType.COMMAND);
await removeDictionary(graphqlClient, channelDictionaryId, DictionaryType.CHANNEL);
await removeDictionary(graphqlClient, parameterDictionaryId, DictionaryType.PARAMETER);
});

it('should return command types', async () => {
Expand Down
Loading

0 comments on commit 1ce729a

Please sign in to comment.